call kill with pid 0. Handle EINTR when receiving messages.
#include <sys/ipc.h>
#include <sys/msg.h>
#include <setjmp.h>
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
jmp_buf msgenv;
if (setjmp (msgenv))
{
msgctl (s, IPC_RMID, 0);
- kill (p, SIGKILL);
+ if (p > 0)
+ kill (p, SIGKILL);
exit (0);
}
signal (SIGTERM, msgcatch);
signal (SIGINT, msgcatch);
+ signal (SIGHUP, msgcatch);
if (p > 0)
{
/* This is executed in the original process that did the fork above. */
{
if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0)
{
+#ifdef EINTR
+ if (errno == EINTR)
+ continue;
+#endif
perror ("msgrcv");
exit (1);
}