40 lines
733 B
C
40 lines
733 B
C
|
#include <unistd.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <assert.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
main(int argc, char *argv[])
|
||
|
{
|
||
|
int no_fds = 0;
|
||
|
int fd = -1;
|
||
|
int rc = 0;
|
||
|
pid_t sid;
|
||
|
|
||
|
/*
|
||
|
* Fork a child process
|
||
|
* Exit parent
|
||
|
* Change directory to "/"
|
||
|
* Redirect stdin, stdout, stderr to "/dev/null"
|
||
|
*/
|
||
|
rc = daemon (0, 0);
|
||
|
if ( rc < 0 )
|
||
|
{
|
||
|
exit(EXIT_FAILURE);
|
||
|
}
|
||
|
|
||
|
/* Create a new session */
|
||
|
setsid();
|
||
|
|
||
|
/* Set the file mode creation mask */
|
||
|
umask(022);
|
||
|
|
||
|
/* Close the associated standard file descriptors */
|
||
|
close(STDIN_FILENO);
|
||
|
close(STDOUT_FILENO);
|
||
|
close(STDERR_FILENO);
|
||
|
|
||
|
/* Start micasad */
|
||
|
return execv ("/usr/bin/mono", argv);
|
||
|
}
|