From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DNS_FROM_AHBL_RHSBL, RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Date: Sun, 9 Aug 2015 10:46:02 +0200 From: Felix Janda To: Linux console tools development discussion Message-ID: <20150809084602.GA13418@nyan> References: <1438225782.2870.2.camel@gmail.com> <20150730173355.GA11486@nyan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150730173355.GA11486@nyan> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [kbd] [PATCHv2] openvt -w: Return exit status from child X-BeenThere: kbd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Linux console tools development discussion List-Id: Linux console tools development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Aug 2015 08:48:47 -0000 Archived-At: List-Archive: 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