]> andersk Git - moira.git/blame_incremental - update/exec_002.c
added new proc type for MOTD
[moira.git] / update / exec_002.c
... / ...
CommitLineData
1/*
2 * $Source$
3 * $Header$
4 */
5/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6/* For copying and distribution information, please see the file */
7/* <mit-copyright.h>. */
8
9#ifndef lint
10static char *rcsid_exec_002_c = "$Header$";
11#endif lint
12
13#include <mit-copyright.h>
14#include <stdio.h>
15#include <sys/wait.h>
16#include <signal.h>
17#include <gdb.h>
18#include <sms.h>
19#include "update.h"
20#include "kludge.h"
21
22extern CONNECTION conn;
23extern int code, errno;
24
25int
26exec_002(str)
27 char *str;
28{
29 union wait waitb;
30 int n, pid, mask;
31
32 str += 8;
33 while (*str == ' ')
34 str++;
35 mask = sigblock(sigmask(SIGCHLD));
36 pid = fork();
37 switch (pid) {
38 case -1:
39 n = errno;
40 sigsetmask(mask);
41 log_priority = log_ERROR;
42 com_err(whoami, errno, ": can't fork to run install script");
43 code = send_object(conn, (char *)&n, INTEGER_T);
44 if (code)
45 exit(1);
46 return;
47 case 0:
48 execlp(str, str, (char *)NULL);
49 n = errno;
50 sigsetmask(mask);
51 log_priority = log_ERROR;
52 com_err(whoami, n, ": %s", str);
53 (void) send_object(conn, (char *)&n, INTEGER_T);
54 exit(1);
55 default:
56 do {
57 n = wait(&waitb);
58 } while (n != -1 && n != pid);
59 sigsetmask(mask);
60 if (waitb.w_status) {
61 n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
62 log_priority = log_ERROR;
63 com_err(whoami, n, " child exited with status %d", waitb.w_retcode);
64 code = send_object(conn, (char *)&n, INTEGER_T);
65 if (code) {
66 exit(1);
67 }
68 } else {
69 code = send_ok();
70 if (code)
71 exit(1);
72 }
73 }
74}
This page took 0.036389 seconds and 5 git commands to generate.