]> andersk Git - moira.git/blame_incremental - update/exec_002.c
Backed out "special" features here (no longer needed)
[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/types.h>
16#include <sys/wait.h>
17#include <signal.h>
18#include <gdb.h>
19#include <moira.h>
20#include "update.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 sigsetmask(mask);
49 execlp(str, str, (char *)NULL);
50 n = errno;
51 sigsetmask(mask);
52 log_priority = log_ERROR;
53 com_err(whoami, n, ": %s", str);
54 (void) send_object(conn, (char *)&n, INTEGER_T);
55 exit(1);
56 default:
57 do {
58 n = wait(&waitb);
59 } while (n != -1 && n != pid);
60 sigsetmask(mask);
61 if (waitb.w_status) {
62 n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
63 log_priority = log_ERROR;
64 com_err(whoami, n, " child exited with status %d", waitb.w_retcode);
65 code = send_object(conn, (char *)&n, INTEGER_T);
66 if (code) {
67 exit(1);
68 }
69 } else {
70 code = send_ok();
71 if (code)
72 exit(1);
73 }
74 }
75}
This page took 0.174291 seconds and 5 git commands to generate.