shell_cmd.c revision 2
2N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * shell_cmd() takes a shell command after %<character> substitutions. The 2N/A * command is executed by a /bin/sh child process, with standard input, 2N/A * standard output and standard error connected to /dev/null. 2N/A * Diagnostics are reported through syslog(3). 2N/A * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 2N/A/* System libraries. */ 2N/A/* Forward declarations. */ 2N/A/* shell_cmd - execute shell command */ 2N/A * Most of the work is done within the child process, to minimize the 2N/A * risk of damage to the parent. 2N/A case -
1:
/* error */ 2N/A case 00:
/* child */ 2N/A default:
/* parent */ 2N/A/* do_child - exec command with { stdin, stdout, stderr } to /dev/null */ 2N/A * Systems with POSIX sessions may send a SIGHUP to grandchildren if the 2N/A * child exits first. This is sick, sessions were invented for terminals. 2N/A /* Set up new stdin, stdout, stderr, and exec the shell command. */ 2N/A /* Something went wrong. We MUST terminate the child process. */