meminfo-writer: kill child if we error out due to failure to write the pid file

This commit is contained in:
Vincent Penquerc'h 2013-12-26 10:39:09 -05:00 committed by Marek Marczykowski-Górecki
parent 1a72505d24
commit 2758d2a1d3

View File

@ -137,11 +137,13 @@ int main(int argc, char **argv)
fd = open(argv[3], O_CREAT | O_TRUNC | O_WRONLY, 0666);
if (fd < 0) {
perror("open pidfile");
kill(pid,9);
exit(1);
}
n = sprintf(buf, "%d\n", pid);
if (write(fd, buf, n) != n) {
perror("write pid");
kill(pid,9);
exit(1);
}
close(fd);