galeb

Једноставна статичка дистрибуција заснована на musl-у
git clone https://git.sr.ht/~strahinja/galeb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

sdhcp-pid-file.patch (901B)


      1 --- sdhcp.c	2022-07-16 22:03:48.635446037 +0200
      2 +++ sdhcp.c	2022-07-20 11:52:33.300996870 +0200
      3 @@ -17,10 +17,13 @@
      4  #include <string.h>
      5  #include <time.h>
      6  #include <unistd.h>
      7 +#include <syslog.h>
      8  
      9  #include "arg.h"
     10  #include "util.h"
     11  
     12 +static const char* pidfile = "/var/run/sdhcp.pid";
     13 +
     14  typedef struct bootp {
     15  	unsigned char op      [1];
     16  	unsigned char htype   [1];
     17 @@ -391,6 +394,7 @@
     18  	int forked = 0, t;
     19  	struct itimerspec timeout = { 0 };
     20  	uint32_t renewaltime, rebindingtime, lease;
     21 +	FILE* pid = NULL;
     22  
     23  Init:
     24  	dhcpsend(DHCPdiscover, Broadcast);
     25 @@ -447,6 +451,13 @@
     26  			exit(0);
     27  		forked = 1;
     28  	}
     29 +	if (!(pid = fopen(pidfile, "w")))
     30 +		syslog(LOG_DAEMON | LOG_ERR, "Cannot open pidfile %s",
     31 +			pidfile);
     32 +	else {
     33 +		fprintf(pid, "%d\n", getpid());
     34 +		fclose(pid);
     35 +	}
     36  	timeout.it_value.tv_sec = renewaltime;
     37  	settimeout(0, &timeout);
     38  	timeout.it_value.tv_sec = rebindingtime;