Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- int main(int argc, char const *argv[]) {
- pid_t pid = fork();
- if (pid) {
- printf("The daemon's PID is %i.\n", pid);
- }
- else {
- printf("The daemon is now running.\n");
- // setsid(); // New SID
- // umask(0); // The deamon can't create files
- // chdir("/"); // Set the cwd to something that always exists
- // fclose(stdin); // We close the
- // fclose(stdout); // common file
- // fclose(stderr); // descriptors
- while(1) {
- sleep(1);
- printf("This is really annoying!\n");
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment