mirror of
https://github.com/eddyem/pusirobot.git
synced 2025-12-06 10:35:11 +03:00
remove pidfile only when parent process died
This commit is contained in:
parent
01e5b454e2
commit
6aec61d4a4
@ -31,11 +31,14 @@
|
|||||||
#include "processmotors.h"
|
#include "processmotors.h"
|
||||||
|
|
||||||
glob_pars *GP; // non-static: to use in outhern functions
|
glob_pars *GP; // non-static: to use in outhern functions
|
||||||
|
static pid_t childpid;
|
||||||
|
|
||||||
void signals(int signo){
|
void signals(int signo){
|
||||||
//restore_tty();
|
//restore_tty();
|
||||||
unlink(GP->pidfile);
|
if(childpid){ // unlink PID-file only from father
|
||||||
LOGERR("Exit with status %d", signo);
|
unlink(GP->pidfile);
|
||||||
|
LOGERR("Exit with status %d", signo);
|
||||||
|
}
|
||||||
exit(signo);
|
exit(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +84,7 @@ int main(int argc, char **argv){
|
|||||||
check4running(self, GP->pidfile);
|
check4running(self, GP->pidfile);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
while(1){ // guard for dead processes
|
while(1){ // guard for dead processes
|
||||||
pid_t childpid = fork();
|
childpid = fork();
|
||||||
if(childpid){
|
if(childpid){
|
||||||
LOGDBG("Create child with PID %d", childpid);
|
LOGDBG("Create child with PID %d", childpid);
|
||||||
DBG("Created child with PID %d\n", childpid);
|
DBG("Created child with PID %d\n", childpid);
|
||||||
|
|||||||
@ -104,7 +104,7 @@ static void *server(void *asock){
|
|||||||
}
|
}
|
||||||
int nfd = 1;
|
int nfd = 1;
|
||||||
// max amount of opened fd (+1 for server socket)
|
// max amount of opened fd (+1 for server socket)
|
||||||
#define MAX_FDS (3)
|
#define MAX_FDS (11)
|
||||||
struct pollfd poll_set[MAX_FDS];
|
struct pollfd poll_set[MAX_FDS];
|
||||||
memset(poll_set, 0, sizeof(poll_set));
|
memset(poll_set, 0, sizeof(poll_set));
|
||||||
poll_set[0].fd = sock;
|
poll_set[0].fd = sock;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user