From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout-kit-02.scc.kit.edu (scc-mailout-kit-02.scc.kit.edu [129.13.231.82]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTP id ceb2149b; for ; Mon, 9 Mar 2015 22:23:43 -0500 (EST) Received: from asta-nat.asta.uni-karlsruhe.de ([172.22.63.82] helo=hekate.usta.de) by scc-mailout-kit-02.scc.kit.edu with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (envelope-from ) id 1YVAlh-0007tI-Qf for tech@mdocml.bsd.lv; Tue, 10 Mar 2015 04:23:42 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1YVAlh-00015O-LN for tech@mdocml.bsd.lv; Tue, 10 Mar 2015 04:23:41 +0100 Received: from athene.usta.de ([172.24.96.10]) by donnerwolke.usta.de with esmtp (Exim 4.80) (envelope-from ) id 1YVAlh-0003UA-Ea for tech@mdocml.bsd.lv; Tue, 10 Mar 2015 04:23:41 +0100 Received: from localhost (1031@localhost [local]); by localhost (OpenSMTPD) with ESMTPA id 656b6eb9; for ; Tue, 10 Mar 2015 04:23:41 +0100 (CET) Date: Tue, 10 Mar 2015 04:23:41 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: [PATCH] Fix "Wait: No Child Process" Message-ID: <20150310032341.GB18431@athene.usta.de> References: <20150302105519.GO13897@ivaldir.etoilebsd.net> <20150302145633.GA28000@athene.usta.de> <54FE0AFA.3070909@bsd.lv> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54FE0AFA.3070909@bsd.lv> User-Agent: Mutt/1.5.23 (2014-03-12) Hi Kristaps, Kristaps Dzonsons wrote on Mon, Mar 09, 2015 at 10:04:58PM +0100: > I'm still getting this error on Mac OS X, only for gzip'd files > when invoked as man(1). Invoking directly as mandoc(1) does not > cause the issue. Gah, there was indeed a second issue causing this symptom, unrelated to the one reported by bapt@. It was introduced as a side effect of main.c rev. 1.212 ("do not spawn a pager when there is no output"). Fixed now... Thanks for reporting, Ingo Log Message: ----------- Fix a regression caused in rev. 1.212, reported by kristaps@: When using a pager and the first manual shown is gzip'ed, the gunzip(1) process ended up as a child of the pager process such that the man(1) process couldn't wait for it, preventing proper display of the manual. Solve this by making the pager a child of the man(1) process (instead of the other way round), which requires being a bit more careful about properly closing file descriptors after use and waiting for the pager before exiting man(1). Modified Files: -------------- mdocml: main.c Revision Data ------------- Index: main.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/main.c,v retrieving revision 1.223 retrieving revision 1.224 diff -Lmain.c -Lmain.c -u -p -r1.223 -r1.224 --- main.c +++ main.c @@ -20,6 +20,7 @@ #include #include /* MACHINE */ +#include #include #include @@ -481,6 +482,21 @@ out: free(defos); + /* + * Flush the output and signal end of file. + * If a pager is attached, it allows browsing to the end. + * Otherwise, it does no harm, we are about to exit anyway. + */ + + fclose(stdout); + + /* + * If we spawned a pager, wait for the user to close it. + * Otherwise, this call fails with no adverse effect. + */ + + wait(NULL); + return((int)rc); } @@ -951,18 +967,19 @@ spawn_pager(void) progname, strerror(errno)); exit((int)MANDOCLEVEL_SYSERR); case 0: + break; + default: close(fildes[0]); if (dup2(fildes[1], STDOUT_FILENO) == -1) { fprintf(stderr, "%s: dup output: %s\n", progname, strerror(errno)); exit((int)MANDOCLEVEL_SYSERR); } + close(fildes[1]); return; - default: - break; } - /* The original process becomes the pager. */ + /* The child process becomes the pager. */ close(fildes[1]); if (dup2(fildes[0], STDIN_FILENO) == -1) { @@ -970,6 +987,7 @@ spawn_pager(void) progname, strerror(errno)); exit((int)MANDOCLEVEL_SYSERR); } + close(fildes[0]); pager = getenv("MANPAGER"); if (pager == NULL || *pager == '\0') -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv