Guest User

Untitled

a guest
Dec 9th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3.  
  4. int main(int argc, char const *argv[]) {
  5. pid_t pid = fork();
  6. if (pid) {
  7. printf("The daemon's PID is %i.\n", pid);
  8. }
  9. else {
  10. printf("The daemon is now running.\n");
  11. // setsid(); // New SID
  12. // umask(0); // The deamon can't create files
  13. // chdir("/"); // Set the cwd to something that always exists
  14.  
  15. // fclose(stdin); // We close the
  16. // fclose(stdout); // common file
  17. // fclose(stderr); // descriptors
  18.  
  19. while(1) {
  20. sleep(1);
  21. printf("This is really annoying!\n");
  22. }
  23. }
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment