|
From: Aaron S. <and...@ra...> - 2003-02-10 01:02:35
|
Here is a simple little replacement for system() that does close file
descriptors. The main issue with it is though, it ends up picking an
arbitrary number of fds to close. I picked closing 0 to 99.
Aaron
int s_system(const char *string)
{
pid_t pid;
int x;
pid = fork()
if(pid == -1)
{
return -1;
}
if(pid > 0)
{
int status;
wait(&status);
return(status);
}
for(x = 0; x < 100; x++)
{
close(x);
}
execlp("/bin/sh", "-c", string);
}
|