Skip to content

Instantly share code, notes, and snippets.

@Osse
Created August 24, 2012 18:05
Show Gist options
  • Save Osse/3453654 to your computer and use it in GitHub Desktop.
Save Osse/3453654 to your computer and use it in GitHub Desktop.
Annoying program
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment