/* * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "common/setup_before.h" #include #ifdef HAVE_STDDEF_H # include #else # ifndef NULL # define NULL ((void *)0) # endif #endif #ifdef STDC_HEADERS # include #endif #ifdef HAVE_STRING_H # include #endif #include #include "compat/strerror.h" #ifdef HAVE_UNISTD_H # include #endif #include "compat/stdfileno.h" #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_WAIT_H # include #endif #include "common/eventlog.h" #include "runprog.h" #include "common/setup_after.h" #ifdef DO_SUBPROC static pid_t currpid=0; #endif extern FILE * runprog_open(char const * command) { #ifndef DO_SUBPROC return NULL; /* always fail */ #else int fds[2]; FILE * pp; if (!command) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL command"); return NULL; } if (pipe(fds)<0) { eventlog(eventlog_level_error,__FUNCTION__,"could not create pipe (pipe: %s)",pstrerror(errno)); return NULL; } switch ((currpid = fork())) { case 0: close(fds[0]); close(STDINFD); close(STDOUTFD); close(STDERRFD); /* FIXME: we should close all other fds to make sure the program doesn't use them. For now, leave it alone because we would either have to keep track of them all or do a for for (fd=0; fd