From: Felix Janda <felix.janda@posteo.de> To: Linux console tools development discussion <kbd@lists.altlinux.org> Subject: [kbd] [PATCHv2] openvt -w: Return exit status from child Date: Sun, 9 Aug 2015 10:46:02 +0200 Message-ID: <20150809084602.GA13418@nyan> (raw) In-Reply-To: <20150730173355.GA11486@nyan> Return 128+signum when child exited because of a signal. --- src/openvt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openvt.c b/src/openvt.c index 1ba8912..4386584 100644 --- a/src/openvt.c +++ b/src/openvt.c @@ -386,7 +386,6 @@ main(int argc, char *argv[]) if (do_wait) { int retval = 0; /* actual value returned form process */ - wait(NULL); waitpid(pid, &retval, 0); if (show) { /* Switch back... */ @@ -403,7 +402,10 @@ main(int argc, char *argv[]) /* if all our stuff went right, we want to return the exit code of the command we ran super vital for scripting loops etc */ - return(retval); + if (WIFEXITED(retval)) + return WEXITSTATUS(retval); + else + return 128 + WTERMSIG(retval); } return EXIT_SUCCESS; -- 2.4.6
prev parent reply other threads:[~2015-08-09 8:46 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-07-30 3:09 [kbd] Return code of openvt command ToBeReplaced 2015-07-30 17:33 ` [kbd] [PATCH] openvt -w: Return exit status from child Felix Janda 2015-08-09 8:46 ` Felix Janda [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20150809084602.GA13418@nyan \ --to=felix.janda@posteo.de \ --cc=kbd@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux console tools development discussion This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/kbd/0 kbd/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 kbd kbd/ http://lore.altlinux.org/kbd \ kbd@lists.altlinux.org kbd@lists.altlinux.ru kbd@lists.altlinux.com public-inbox-index kbd Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.kbd AGPL code for this site: git clone https://public-inbox.org/public-inbox.git