diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-06-24 20:12:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-06-24 20:12:21 -0700 |
commit | a005758be5966320890e057ce35ee5ecfb905c15 (patch) | |
tree | 1090d5472942c748fba83f48bd9ffa1b381be52d | |
parent | 29b6a140e1bbf606c762da5f4555dbb2fba97dcb (diff) | |
download | txr-a005758be5966320890e057ce35ee5ecfb905c15.tar.gz txr-a005758be5966320890e057ce35ee5ecfb905c15.tar.bz2 txr-a005758be5966320890e057ce35ee5ecfb905c15.zip |
close-stream: process wait cleanup.
* stream.c (pipe_close_status_helper): Revise error messages.
Get rid of impossible cases: we will not get WIFSTOPPED or
WIFCONTINUED unless we used the WUNTRACED option in waitpid,
which we don't. No platforms without HAVE_SYS_WAIT, don't throw
if the status is nonzero; just return nil. It could be a normal
termination.
-rw-r--r-- | stream.c | 24 |
1 files changed, 6 insertions, 18 deletions
@@ -1367,33 +1367,21 @@ val pipe_close_status_helper(val stream, val throw_on_error, if (status < 0) { if (throw_on_error) uw_ethrowf(process_error_s, - lit("~a: unable to obtain status of command ~s: ~d/~s"), + lit("~a: stream ~s: unable to obtain status of process: ~d/~s"), self, stream, num(errno), errno_to_str(errno), nao); return nil; } else { #if HAVE_SYS_WAIT - if (default_null_arg(throw_on_error)) { + if (WIFEXITED(status)) { + int exitstatus = WEXITSTATUS(status); + return num(exitstatus); + } else if (default_null_arg(throw_on_error)) { if (WIFSIGNALED(status)) { int termsig = WTERMSIG(status); - uw_throwf(process_error_s, lit("~a: pipe ~s terminated by signal ~a"), + uw_throwf(process_error_s, lit("~a: stream ~s: process terminated by signal ~a"), self, stream, num(termsig), nao); -#ifndef WIFCONTINUED -#define WIFCONTINUED(X) 0 -#endif - } else if (WIFSTOPPED(status) || WIFCONTINUED(status)) { - uw_throwf(process_error_s, - lit("~s, processes of closed pipe ~s still running"), - self, stream, nao); } } - if (WIFEXITED(status)) { - int exitstatus = WEXITSTATUS(status); - return num(exitstatus); - } -#else - if (status != 0 && default_null_arg(throw_on_error)) - uw_throwf(process_error_s, lit("~a: closing pipe ~s failed"), - self, stream, nao); #endif return status == 0 ? zero : nil; } |