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: Thu, 30 Jul 2015 19:33:55 +0200 From: Felix Janda To: Linux console tools development discussion Message-ID: <20150730173355.GA11486@nyan> References: <1438225782.2870.2.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438225782.2870.2.camel@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [kbd] [PATCH] 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: Thu, 30 Jul 2015 17:34:58 -0000 Archived-At: List-Archive: --- ToBeReplaced wrote: > On openvt from kbd 2.0.2, `openvt -c 1 -fw /bin/false` exits with > return code 0 instead of 1. Can confirm on current git. > There's a bug report from 2003 and a claim that it was resolved as of > kbd 1.14.1: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=190386 The relevant commit is e37c78afc7fcee6d8edaa506b99d9081249adb7d. Maybe it got broken since. Possibly it never worked at all. > I'm not sure if this is a bug or desired behavior. > > How can I get the return code of the command passed to openvt? Try this patch. --- src/openvt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/openvt.c b/src/openvt.c index 1ba8912..1a36a69 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,7 @@ 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); + return WEXITSTATUS(retval); } return EXIT_SUCCESS; -- 2.3.6