lib/process.c
/* Given 'status', which is a process status in the form reported by waitpid(2)
 * and returned by process_status(), returns a string describing how the
 * process terminated.  The caller is responsible for freeing the string when
 * it is no longer needed. */
Given 'status', which is a process status in the form reported by waitpid(2)
and returned by process_status(), returns a string describing how the
process terminated.  The caller is responsible for freeing the string when
it is no longer needed.
Given ' status ' which is a process status in the form reported by waitpid ( 2 ) and returned by process_status () returns a string describing how the process terminated . The caller is responsible for freeing the string when it is no longer needed .
char *
process_status_msg(int status)
{
    struct ds ds = DS_EMPTY_INITIALIZER;
#ifndef _WIN32
    if (WIFEXITED(status)) {
        ds_put_format(&ds, "exit status %d", WEXITSTATUS(status));
    } else if (WIFSIGNALED(status)) {
        char namebuf[SIGNAL_NAME_BUFSIZE];
        ds_put_format(&ds, "killed (%s)",
                      signal_name(WTERMSIG(status), namebuf, sizeof namebuf));
    } else if (WIFSTOPPED(status)) {
        char namebuf[SIGNAL_NAME_BUFSIZE];
        ds_put_format(&ds, "stopped (%s)",
                      signal_name(WSTOPSIG(status), namebuf, sizeof namebuf));
    } else {
        ds_put_format(&ds, "terminated abnormally (%x)", status);
    }
    if (WCOREDUMP(status)) {
        ds_put_cstr(&ds, ", core dumped");
    }
#else
    ds_put_cstr(&ds, "function not supported.");
#endif
    return ds_cstr(&ds);
}
char * process_status_msg ( int status ) { struct ds ds = DS_EMPTY_INITIALIZER ; #ifndef _WIN32 if ( WIFEXITED ( status ) ) { ds_put_format ( & ds , " " , WEXITSTATUS ( status ) ) ; } else if ( WIFSIGNALED ( status ) ) { char namebuf [ SIGNAL_NAME_BUFSIZE ] ; ds_put_format ( & ds , " " , signal_name ( WTERMSIG ( status ) , namebuf , sizeof namebuf ) ) ; } else if ( WIFSTOPPED ( status ) ) { char namebuf [ SIGNAL_NAME_BUFSIZE ] ; ds_put_format ( & ds , " " , signal_name ( WSTOPSIG ( status ) , namebuf , sizeof namebuf ) ) ; } else { ds_put_format ( & ds , " " , status ) ; } if ( WCOREDUMP ( status ) ) { ds_put_cstr ( & ds , " " ) ; } #else ds_put_cstr ( & ds , " " ) ; #endif return ds_cstr ( & ds ) ; }
Given 'status', which is a process status in the form reported by waitpid(2)
 and returned by process_status(), returns a string describing how the
 process terminated.
Given ' status ' which is a process status in the form reported by waitpid ( 2 ) and returned by process_status () returns a string describing how the process terminated .