meminfo-writer: kill child if we error out due to failure to write the pid file
This commit is contained in:
parent
1a72505d24
commit
2758d2a1d3
@ -137,11 +137,13 @@ int main(int argc, char **argv)
|
|||||||
fd = open(argv[3], O_CREAT | O_TRUNC | O_WRONLY, 0666);
|
fd = open(argv[3], O_CREAT | O_TRUNC | O_WRONLY, 0666);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror("open pidfile");
|
perror("open pidfile");
|
||||||
|
kill(pid,9);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
n = sprintf(buf, "%d\n", pid);
|
n = sprintf(buf, "%d\n", pid);
|
||||||
if (write(fd, buf, n) != n) {
|
if (write(fd, buf, n) != n) {
|
||||||
perror("write pid");
|
perror("write pid");
|
||||||
|
kill(pid,9);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user