From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31571 invoked by alias); 14 May 2011 14:11:31 -0000 Received: (qmail 31560 invoked by uid 22791); 14 May 2011 14:11:30 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CL X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 14 May 2011 14:11:17 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/48961] EXECUTE_COMMAND_LINE(WAIT=.false.) fails on MinGW X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 14 May 2011 14:16:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg01159.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48961 --- Comment #9 from Tobias Burnus 2011-05-14 14:00:26 UTC --- (In reply to comment #8) > We fork() and then call system(), which forks again and runs a shell, then the > shell exits, the forked process inside system() exits, the we exit our forked > process. > > I think we might as well just fork and exec the shell directly which would save > one process creation. We also don't need the exit value from the system() call > in Fortran. POSIX states for "system": "The environment of the executed command shall be as if a child process were created using fork(), and the child process invoked the sh utility using execl() as follows: execl(, "sh", "-c", command, (char *)0); where is an unspecified pathname for the sh utility." Thus, for a POSIX system, one could use: execlp ("sh", "sh", "-c", command, (char*) 0); However, that assumes that there is a "sh" available. That's the advantage of "system()" that it is widely available and one avoids to specify the shell commands. One cannot do without the shell command as there are users, who want that using 'system("./foo > bar.dat")' works. Thus, I do not see how one can solve this better than currently done.