|
From: | Antonio Diaz Diaz |
Subject: | Re: [Bug-ddrescue] 2 Suggestions (bi-directional retry and user interruption exit code) |
Date: | Fri, 21 Feb 2014 20:17:17 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.11) Gecko/20050905 |
Scott D wrote:
This is with non-modified ddrescue.
Then Ctrl-c can't be reliably differentiated from a normal exit with 0 status.
I was looking at the return value raw, not using the proper WEXITSTATUS, and found it to not be zero if terminated by ctrl-c. I believe the value would was 0x0200, showing the SIGNT as the high order byte.
You can't use the status returned by waitpid this way. It includes several values and must be tested with the corresponding macros[1] like this:
if( WIFEXITED( status ) ) return WEXITSTATUS( status ); [1]http://www.gnu.org/software/libc/manual/html_node/Process-Completion-Status.html
So I do believe that the only sure way to tell if ddrescue was terminated by the user is to make it exit with a nonzero value.
It is the safest option (in case someone uses 'status & 0xFF' as return value), but it is quite a change to consider an user-finished run as an error.
[Prev in Thread] | Current Thread | [Next in Thread] |