FreeCalypso > hg > freecalypso-tools
comparison rvinterf/lowlevel/rvifmain.c @ 761:32031c18cc25
rvinterf -b: write pid to /tmp/rvinterf.pid
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 02 Dec 2020 19:49:23 +0000 |
parents | d43dc6dfb44c |
children | a1065c17429c |
comparison
equal
deleted
inserted
replaced
760:e1c8c5bcb233 | 761:32031c18cc25 |
---|---|
38 | 38 |
39 static char keepalive_msg[] = | 39 static char keepalive_msg[] = |
40 "Received keepalive query, responding with keepalive answer"; | 40 "Received keepalive query, responding with keepalive answer"; |
41 static u_char keepalive_answer[2] = {RVT_KEEPALIVE_HEADER, 'A'}; | 41 static u_char keepalive_answer[2] = {RVT_KEEPALIVE_HEADER, 'A'}; |
42 | 42 |
43 write_pid_file(pid) | |
44 { | |
45 static char pid_filename[] = "/tmp/rvinterf.pid"; | |
46 FILE *of; | |
47 | |
48 of = fopen(pid_filename, "w"); | |
49 if (!of) { | |
50 fprintf(stderr, "warning: unable to write %s\n", pid_filename); | |
51 return(-1); | |
52 } | |
53 fprintf(of, "%d\n", pid); | |
54 fclose(of); | |
55 return(0); | |
56 } | |
57 | |
43 main(argc, argv) | 58 main(argc, argv) |
44 char **argv; | 59 char **argv; |
45 { | 60 { |
46 extern char *optarg; | 61 extern char *optarg; |
47 extern int optind; | 62 extern int optind; |
119 perror("fork"); | 134 perror("fork"); |
120 exit(1); | 135 exit(1); |
121 } | 136 } |
122 if (c) { | 137 if (c) { |
123 printf("rvinterf forked into background (pid %d)\n", c); | 138 printf("rvinterf forked into background (pid %d)\n", c); |
139 write_pid_file(c); | |
124 exit(0); | 140 exit(0); |
125 } | 141 } |
126 } | 142 } |
127 signal(SIGPIPE, SIG_IGN); | 143 signal(SIGPIPE, SIG_IGN); |
128 pwon_if_needed(); | 144 pwon_if_needed(); |