/*
- * $Header$
+ * $Header$
*/
#ifndef lint
#endif lint
-
/************************************************************************
*
* gdb_fserv.c
#include <sys/signal.h>
#include "gdb.h"
#include <sys/resource.h>
-\f
+
+
/************************************************************************
*
* create_forking_server (create_forking_server)
/* Called on SIGCHILD to reap all dead children.
/*
/************************************************************************/
+#ifndef POSIX
int
+#else
+void
+#endif
gdb_reaper()
{
+#ifdef POSIX
+ int status;
+#else
union wait status;
+#endif
extern char *sys_siglist[];
- while (wait3(&status, WNOHANG, (struct rusage *)0) >0) {
-#ifdef notdef
- if (WIFEXITED(status)) {
- if (status.w_retcode)
- printf("exited with code %d\n",
- status.w_retcode);
- }
- if (WIFSIGNALED(status)) {
- printf("exited on %s signal%s\n",
- sys_siglist[status.w_termsig],
- (status.w_coredump?"; core dumped":0));
- }
-#endif notdef
- }
+#ifdef POSIX
+ while (waitpid(-1, &status, WNOHANG) >0);
+#else
+ while (wait3(&status, WNOHANG, (struct rusage *)0) >0);
+#endif
}
\f
/************************************************************************/
int
g_do_signals()
{
- (void) signal(SIGCHLD, gdb_reaper);
+#ifdef POSIX
+ struct sigaction act;
+
+ act.sa_handler = gdb_reaper;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ (void) sigaction(SIGCHLD, &act, (struct sigaction *)0);
+#else /* sun */
+ (void) signal(SIGCHLD, gdb_reaper);
+#endif
}