]> andersk Git - moira.git/commitdiff
reap children
authormar <mar>
Fri, 25 Aug 1989 14:39:32 +0000 (14:39 +0000)
committermar <mar>
Fri, 25 Aug 1989 14:39:32 +0000 (14:39 +0000)
server/mr_glue.c

index c6439b8a126eef77ee60f022022cc16f6c75a4af..517f8b09a01474df65f55b4a1ee866d7da330c60 100644 (file)
@@ -17,6 +17,9 @@ static char *rcsid_sms_glue_c = "$Header$";
 
 #include <mit-copyright.h>
 #include "sms_server.h"
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/wait.h>
 #include <krb_et.h>
 #include <pwd.h>
 #include "query.h"
@@ -29,6 +32,7 @@ static client pseudo_client;
 extern int errno;
 extern char *malloc(), *whoami;
 extern time_t now;
+void reapchild();
 
 sms_connect(server)
 char *server;
@@ -45,6 +49,8 @@ char *server;
     query_timeout = 0;
     status =  sms_open_database();
     if (!status) already_connected = 1;
+
+    signal(SIGCHLD, reapchild);
     return status;
 }
 
@@ -84,10 +90,10 @@ char *prog;
     strcpy(buf, pw->pw_name);
     strcat(buf, "@");
     strcat(buf, pseudo_client.kname.realm);
-    pseudo_client.clname = malloc(strlen(buf)+1);
     strcpy(pseudo_client.clname, buf);
     pseudo_client.users_id = get_users_id(pseudo_client.kname.name);
-    pseudo_client.entity = strsave(prog);
+    pseudo_client.client_id = pseudo_client.users_id;
+    strcpy(pseudo_client.entity, prog);
     pseudo_client.args = (sms_params *) malloc(sizeof(sms_params));
     pseudo_client.args->sms_version_no = SMS_VERSION_2;
     return 0;
@@ -196,3 +202,16 @@ trigger_dcm(dummy0, dummy1, cl)
                return(SMS_SUCCESS);
        }
 }
+
+
+void reapchild()
+{
+    union wait status;
+    int pid;
+
+    while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) > 0) {
+       if  (status.w_termsig != 0 || status.w_retcode != 0)
+         com_err(whoami, 0, "%d: child exits with signal %d status %d",
+                 pid, status.w_termsig, status.w_retcode);
+    }
+}
This page took 0.069665 seconds and 5 git commands to generate.