System call in C

Len Reed lbr at holos0.uucp
Tue May 14 00:24:34 AEST 1991


In article <53 at swatty.UUCP> krone%swatty at 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



More information about the Comp.unix.xenix.sco mailing list