mirror of
https://github.com/eddyem/snippets_library.git
synced 2026-06-21 18:56:23 +03:00
Compare commits
2 Commits
2525224423
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f1162e4df1 | |||
| 850002d800 |
8
daemon.c
8
daemon.c
@@ -140,9 +140,11 @@ int sl_daemonize(){
|
|||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
close(STDERR_FILENO);
|
close(STDERR_FILENO);
|
||||||
if(open("/dev/null", O_RDWR) < 0) return -1;
|
int ofd = open("/dev/null", O_RDWR);
|
||||||
if(dup(0) < 0) return -1;
|
if(ofd < 0) return -1;
|
||||||
if(dup(0) < 0) return -1;
|
if(dup(ofd) < 0) return -1; // STDIN
|
||||||
|
if(dup(ofd) < 0) return -1; // STDOUT
|
||||||
|
if(dup(ofd) < 0) return -1; // STDERR
|
||||||
if(SIG_ERR == signal(SIGHUP, SIG_IGN)) return -1;
|
if(SIG_ERR == signal(SIGHUP, SIG_IGN)) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
2
socket.c
2
socket.c
@@ -738,7 +738,7 @@ int sl_sock_open(sl_socktype_e type, const char *path, int isserver, int ai_sock
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(connect(sock, p->ai_addr, p->ai_addrlen) == -1){
|
if(connect(sock, p->ai_addr, p->ai_addrlen) == -1){
|
||||||
WARN("connect()");
|
//WARN("connect()");
|
||||||
close(sock); sock = -1;
|
close(sock); sock = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user