Created
July 17, 2011 05:55
-
-
Save mitsuji/1087253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <signal.h> | |
#include <HsFFI.h> | |
#include "HDaemon/Daemon_stub.h" | |
extern void __stginit_HDaemonziDaemon(void); | |
int save_pid() | |
{ | |
pid_t pid = getpid(); | |
FILE* file = fopen("/var/run/hdaemon.pid","w"); | |
char buff[20]; | |
sprintf(buff,"%d",pid); | |
fputs(buff,file); | |
fclose(file); | |
return 0; | |
} | |
int main(int argc, char* argv[]) | |
{ | |
int r = daemon(0,0); | |
int p = save_pid(); | |
hs_init(&argc, &argv); | |
hs_add_root(__stginit_HDaemonziDaemon); | |
foreignMain(); | |
hs_exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment