Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
pid_t pid, pid2;
int ret;
ssize_t n;
+ int pidfile_fd;
+ char pidstr[20] = { 0 };
ret = pipe(fd);
assert(ret == 0);
assert(n == sizeof(ret));
assert(ret == 1);
+ ret = stat(pidfile, &st);
+ assert(ret == 0);
+ assert(S_ISREG(st.st_mode));
+
+ pidfile_fd = open(pidfile, O_RDONLY, 0644);
+ assert(pidfile_fd != -1);
+ n = read(pidfile_fd, pidstr, sizeof(pidstr)-1);
+ assert(n != -1);
+ pid2 = (pid_t)atoi(pidstr);
+ assert(pid == pid2);
+
ret = kill(pid, SIGHUP);
assert(ret == 0);