Re: timeout fix for linux

Keresztfalvi Laszlo <[email protected]> Mon, 22 Jan 2007 11:16:01 +0100
Newsgroups gmane.comp.security.forensics.tct
Message-ID <[email protected]>
Wietse Venema wrote:
> 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.

The problem is that one exit value could not contain both.. The shell returns 8 bit exit 
code (try 'exit 300', returns 44), so there is no space to hold WTERMSIG in a shell 
environment, I think.

For me, the exit status of the called command is more important and so the "general" -1 
(=255) failure in case of a kill is good enough.
Why: the command started with the time bound because it might fail and -1 usually means 
unknown error.. which needs retry or further investigation.. like when the command could 
not finish in reasonable time.

OK, thats my opinion. Maybe, a required option for timeout specifying the exit value for a 
kill could solve this paradox or at least warn the user about.

Laszlo