Re: timeout fix for linux
[email protected] (Wietse Venema) Fri, 19 Jan 2007 14:25:28 -0500 (EST)
| Newsgroups | gmane.comp.security.forensics.tct |
|---|---|
| Message-ID | <[email protected]> |
Keresztfalvi Laszlo:
[ Charset ISO-8859-2 unsupported, converting... ]
> The man timeout page says:
> "timeout's exit status is the exit status of the specified command
> or 1 in case of a usage error."
>
> My problem was that the executed command failed with exit value other than 0 (eg. sqlplus
> and 174) in time. But timeout returned 0, so the script assumed the call was successful. I
> only touched the code of the returned value surrounding status with the appropriate macro.
>
> Sure, it may interfere when the command also returns -1 or 255 but these values usually
> means fatal, unknown errors without useful meanings. I think this is not a problem (at
> least the problem remains problem), while reporting success instead of failure is danger.
>
> That's all. I thought others may also assume the above operation.. Feel free to include or
> drop.
The original code loses a non-zero command exit status and does
report whether the command was killed due to a signal.
Your patch keeps the non-zero command exit status and loses that
the command was killed due to a signal.
Your patch replaces one bug by another, and that is not progress.
I sent someone a diff last week that reports the command's non-zero exit
status, and that also returns a nonzero exit status when the
command was terminated by a signal.
The line in question is:
return (pid == child_pid ? WEXITSTATUS(status) | WTERMSIG(status) : -1);
It's not pretty but at least it does not lose information.
Wietse