http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48961
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 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(<shell path>, "sh", "-c", command, (char *)0); where <shell path> 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.