Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!wa4mei!holos0!lbr From: lbr@holos0.uucp (Len Reed) Newsgroups: comp.unix.xenix.sco Subject: Re: System call in C Message-ID: <1991May13.142434.18200@holos0.uucp> Date: 13 May 91 14:24:34 GMT References: <53@swatty.UUCP> Organization: Holos Software, Inc., Atlanta, GA Lines: 26 In article <53@swatty.UUCP> krone%swatty@attmail.com (Larry Krone) writes: >I am writing a program in C that issues a command to the shell via the system >function. I do not want anything to print from the executed command. > >Appending a > /dev/null on the end of the command does not seem to work... You must redirect stderr (handle 2), too. system("command args >/dev/null 2>/dev/null") or system("command args >/dev/null 2>&1") (The second version says duplicate handle 2 as a copy of 1, which is of course already open to /dev/null.) This won't disconnect the process from the tty, though, so if it opens "/dev/tty" and writes to it stronger measures are required. -- Len Reed Holos Software, Inc. Voice: (404) 496-1358 UUCP: ...!gatech!holos0!lbr