root@swatty.UUCP (Larry Krone) (05/13/91)
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... Any ideas would be appreciated.... Larry Krone
lbr@holos0.uucp (Len Reed) (05/13/91)
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