]>
diplodocus.org Git - nmh/blob - sbr/context_save.c
3 * context_save.c -- write out the updated context file
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
11 * This function used to support setuid/setgid programs by writing
12 * the file as the user. But that code, m_chkids(), was removed
13 * because there no longer are setuid/setgid programs in nmh.
17 #include <h/signals.h>
22 register struct node
*np
;
25 int failed_to_lock
= 0;
27 /* No context in use -- silently ignore any changes! */
31 if (!(ctxflags
& CTXMOD
))
35 /* block a few signals */
37 sigaddset (&set
, SIGHUP
);
38 sigaddset (&set
, SIGINT
);
39 sigaddset (&set
, SIGQUIT
);
40 sigaddset (&set
, SIGTERM
);
41 sigprocmask (SIG_BLOCK
, &set
, &oset
);
43 if (!(out
= lkfopendata (ctxpath
, "w", &failed_to_lock
))) {
45 adios (ctxpath
, "failed to lock");
47 adios (ctxpath
, "unable to write");
50 for (np
= m_defs
; np
; np
= np
->n_next
)
52 fprintf (out
, "%s: %s\n", np
->n_name
, np
->n_field
);
53 lkfclosedata (out
, ctxpath
);
55 sigprocmask (SIG_SETMASK
, &oset
, &set
); /* reset the signal mask */