Where did that ! come from ;-)
What about this code:
int fd;
if(fork())
exit(0);
setsid();
close(0);
open("/dev/null, O_RDONLY);
if (close(dup(1)) != 0) {
close(1);
open("/dev/null, O_WRONLY);
}
if (close(dup(2)) != 0) {
dup2(1,2);
}
Keep stdout/stderr if open, else use /dev/null.
---
Henrik Nordstrom
