collect.c revision 1.37 1 /* $NetBSD: collect.c,v 1.37 2006/11/28 18:45:32 christos Exp $ */
2
3 /*
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 #ifndef lint
34 #if 0
35 static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
36 #else
37 __RCSID("$NetBSD: collect.c,v 1.37 2006/11/28 18:45:32 christos Exp $");
38 #endif
39 #endif /* not lint */
40
41 /*
42 * Mail -- a mail program
43 *
44 * Collect input from standard input, handling
45 * ~ escapes.
46 */
47
48 #include <assert.h>
49 #include <util.h>
50
51 #include "rcv.h"
52 #include "extern.h"
53 #include "format.h"
54 #ifdef MIME_SUPPORT
55 #include "mime.h"
56 #endif
57 #include "thread.h"
58
59
60 /*
61 * Read a message from standard input and return a read file to it
62 * or NULL on error.
63 */
64
65 /*
66 * The following hokiness with global variables is so that on
67 * receipt of an interrupt signal, the partial message can be salted
68 * away on dead.letter.
69 */
70
71 static sig_t saveint; /* Previous SIGINT value */
72 static sig_t savehup; /* Previous SIGHUP value */
73 static sig_t savetstp; /* Previous SIGTSTP value */
74 static sig_t savettou; /* Previous SIGTTOU value */
75 static sig_t savettin; /* Previous SIGTTIN value */
76 static FILE *collf; /* File for saving away */
77 static int hadintr; /* Have seen one SIGINT so far */
78
79 static jmp_buf colljmp; /* To get back to work */
80 static int colljmp_p; /* whether to long jump */
81 static jmp_buf collabort; /* To end collection with error */
82
83
84 /*
85 * Write a file, ex-like if f set.
86 */
87 static int
88 exwrite(const char name[], FILE *fp, int f)
89 {
90 FILE *of;
91 int c;
92 long cc;
93 int lc;
94 struct stat junk;
95
96 if (f) {
97 (void)printf("\"%s\" ", name);
98 (void)fflush(stdout);
99 }
100 if (stat(name, &junk) >= 0 && S_ISREG(junk.st_mode)) {
101 if (!f)
102 (void)fprintf(stderr, "%s: ", name);
103 (void)fprintf(stderr, "File exists\n");
104 return -1;
105 }
106 if ((of = Fopen(name, "w")) == NULL) {
107 warn("%s", name);
108 return -1;
109 }
110 lc = 0;
111 cc = 0;
112 while ((c = getc(fp)) != EOF) {
113 cc++;
114 if (c == '\n')
115 lc++;
116 (void)putc(c, of);
117 if (ferror(of)) {
118 warn("%s", name);
119 (void)Fclose(of);
120 return -1;
121 }
122 }
123 (void)Fclose(of);
124 (void)printf("%d/%ld\n", lc, cc);
125 (void)fflush(stdout);
126 return 0;
127 }
128
129 /*
130 * Edit the message being collected on fp.
131 * On return, make the edit file the new temp file.
132 */
133 static void
134 mesedit(FILE *fp, int c)
135 {
136 sig_t sigint = signal(SIGINT, SIG_IGN);
137 FILE *nf = run_editor(fp, (off_t)-1, c, 0);
138
139 if (nf != NULL) {
140 (void)fseek(nf, 0L, 2);
141 collf = nf;
142 (void)Fclose(fp);
143 }
144 (void)signal(SIGINT, sigint);
145 }
146
147 /*
148 * Pipe the message through the command.
149 * Old message is on stdin of command;
150 * New message collected from stdout.
151 * Sh -c must return 0 to accept the new message.
152 */
153 static void
154 mespipe(FILE *fp, char cmd[])
155 {
156 FILE *nf;
157 sig_t sigint = signal(SIGINT, SIG_IGN);
158 const char *shellcmd;
159 int fd;
160 char tempname[PATHSIZE];
161
162 (void)snprintf(tempname, sizeof(tempname),
163 "%s/mail.ReXXXXXXXXXX", tmpdir);
164 if ((fd = mkstemp(tempname)) == -1 ||
165 (nf = Fdopen(fd, "w+")) == NULL) {
166 if (fd != -1)
167 (void)close(fd);
168 warn("%s", tempname);
169 goto out;
170 }
171 (void)unlink(tempname);
172 /*
173 * stdin = current message.
174 * stdout = new message.
175 */
176 if ((shellcmd = value(ENAME_SHELL)) == NULL)
177 shellcmd = _PATH_CSHELL;
178 if (run_command(shellcmd,
179 0, fileno(fp), fileno(nf), "-c", cmd, NULL) < 0) {
180 (void)Fclose(nf);
181 goto out;
182 }
183 if (fsize(nf) == 0) {
184 (void)fprintf(stderr, "No bytes from \"%s\" !?\n", cmd);
185 (void)Fclose(nf);
186 goto out;
187 }
188 /*
189 * Take new files.
190 */
191 (void)fseek(nf, 0L, 2);
192 collf = nf;
193 (void)Fclose(fp);
194 out:
195 (void)signal(SIGINT, sigint);
196 }
197
198 /*
199 * Interpolate the named messages into the current
200 * message, preceding each line with a tab.
201 * Return a count of the number of characters now in
202 * the message, or -1 if an error is encountered writing
203 * the message temporary. The flag argument is 'm' if we
204 * should shift over and 'f' if not.
205 */
206 static int
207 forward(char ms[], FILE *fp, char *fn, int f)
208 {
209 int *msgvec;
210 struct ignoretab *ig;
211 const char *tabst;
212 #ifdef MIME_SUPPORT
213 struct mime_info *mip;
214 int retval;
215 #endif
216 msgvec = salloc((get_msgCount() + 1) * sizeof *msgvec);
217 if (msgvec == NULL)
218 return 0;
219 if (getmsglist(ms, msgvec, 0) < 0)
220 return 0;
221 if (*msgvec == 0) {
222 *msgvec = first(0, MMNORM);
223 if (*msgvec == 0) {
224 (void)printf("No appropriate messages\n");
225 return 0;
226 }
227 msgvec[1] = 0;
228 }
229 if (f == 'f' || f == 'F')
230 tabst = NULL;
231 else if ((tabst = value(ENAME_INDENTPREFIX)) == NULL)
232 tabst = "\t";
233 ig = isupper(f) ? NULL : ignore;
234 (void)printf("Interpolating:");
235 for (; *msgvec != 0; msgvec++) {
236 struct message *mp;
237 char *fmtstr;
238
239 mp = get_message(*msgvec);
240 touch(mp);
241 (void)printf(" %d", *msgvec);
242 (void)fflush(stdout); /* flush stdout and the above */
243
244 if (tabst && (fmtstr = value(ENAME_INDENT_PREAMBLE)) != NULL)
245 fmsgprintf(collf, fmtstr, mp);
246 #ifdef MIME_SUPPORT
247 mip = NULL;
248 if (value(ENAME_MIME_DECODE_MSG)) {
249 if ((tabst == NULL && value(ENAME_MIME_DECODE_INSERT)) ||
250 (tabst != NULL && value(ENAME_MIME_DECODE_QUOTE)))
251 mip = mime_decode_open(mp);
252 }
253 retval = mime_sendmessage(mp, fp, ig, tabst, mip);
254 mime_decode_close(mip);
255 if (retval < 0)
256 #else
257 if (sendmessage(mp, fp, ig, tabst, NULL) < 0)
258 #endif
259 {
260 warn("%s", fn);
261 return -1;
262 }
263 if (tabst && (fmtstr = value(ENAME_INDENT_POSTSCRIPT)) != NULL)
264 fmsgprintf(collf, fmtstr, mp);
265
266 }
267 (void)printf("\n");
268 return 0;
269 }
270
271 /*
272 * Print (continue) when continued after ^Z.
273 */
274 /*ARGSUSED*/
275 static void
276 collstop(int s)
277 {
278 sig_t old_action = signal(s, SIG_DFL);
279 sigset_t nset;
280
281 (void)sigemptyset(&nset);
282 (void)sigaddset(&nset, s);
283 (void)sigprocmask(SIG_UNBLOCK, &nset, NULL);
284 (void)kill(0, s);
285 (void)sigprocmask(SIG_BLOCK, &nset, NULL);
286 (void)signal(s, old_action);
287 if (colljmp_p) {
288 colljmp_p = 0;
289 hadintr = 0;
290 longjmp(colljmp, 1);
291 }
292 }
293
294 /*
295 * Append the contents of the file to the end of the deadletter file.
296 */
297 PUBLIC void
298 savedeadletter(FILE *fp)
299 {
300 FILE *dbuf;
301 mode_t m;
302 int c;
303 const char *cp;
304
305 if (fsize(fp) == 0)
306 return;
307 cp = getdeadletter();
308 m = umask(077);
309 dbuf = Fopen(cp, "a");
310 (void)umask(m);
311 if (dbuf == NULL)
312 return;
313 while ((c = getc(fp)) != EOF)
314 (void)putc(c, dbuf);
315 (void)Fclose(dbuf);
316 rewind(fp);
317 }
318
319 /*
320 * On interrupt, come here to save the partial message in ~/dead.letter.
321 * Then jump out of the collection loop.
322 */
323 /*ARGSUSED*/
324 static void
325 collint(int s __unused)
326 {
327 /*
328 * the control flow is subtle, because we can be called from ~q.
329 */
330 if (!hadintr) {
331 if (value(ENAME_IGNORE) != NULL) {
332 (void)puts("@");
333 (void)fflush(stdout);
334 clearerr(stdin);
335 return;
336 }
337 hadintr = 1;
338 longjmp(colljmp, 1);
339 }
340 rewind(collf);
341 if (value(ENAME_NOSAVE) == NULL)
342 savedeadletter(collf);
343 longjmp(collabort, 1);
344 }
345
346 /*ARGSUSED*/
347 static void
348 collhup(int s __unused)
349 {
350 rewind(collf);
351 savedeadletter(collf);
352 /*
353 * Let's pretend nobody else wants to clean up,
354 * a true statement at this time.
355 */
356 exit(1);
357 }
358
359 PUBLIC FILE *
360 collect(struct header *hp, int printheaders)
361 {
362 FILE *fbuf;
363 int lc, cc;
364 int c, fd, t;
365 char linebuf[LINESIZE];
366 const char *cp;
367 char tempname[PATHSIZE];
368 char mailtempname[PATHSIZE];
369 int lastlong, rc; /* So we don't make 2 or more lines
370 out of a long input line. */
371 int eofcount;
372 int longline;
373 sigset_t nset;
374
375 /* The following are declared volatile to avoid longjmp clobbering. */
376 char volatile getsub;
377 int volatile escape;
378
379 (void)memset(mailtempname, 0, sizeof(mailtempname));
380 collf = NULL;
381 /*
382 * Start catching signals from here, but we're still die on interrupts
383 * until we're in the main loop.
384 */
385 (void)sigemptyset(&nset);
386 (void)sigaddset(&nset, SIGINT);
387 (void)sigaddset(&nset, SIGHUP);
388 (void)sigprocmask(SIG_BLOCK, &nset, NULL);
389 if ((saveint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
390 (void)signal(SIGINT, collint);
391 if ((savehup = signal(SIGHUP, SIG_IGN)) != SIG_IGN)
392 (void)signal(SIGHUP, collhup);
393 savetstp = signal(SIGTSTP, collstop);
394 savettou = signal(SIGTTOU, collstop);
395 savettin = signal(SIGTTIN, collstop);
396 if (setjmp(collabort) || setjmp(colljmp)) {
397 (void)rm(mailtempname);
398 goto err;
399 }
400 (void)sigprocmask(SIG_UNBLOCK, &nset, NULL);
401
402 noreset++;
403 (void)snprintf(mailtempname, sizeof(mailtempname),
404 "%s/mail.RsXXXXXXXXXX", tmpdir);
405 if ((fd = mkstemp(mailtempname)) == -1 ||
406 (collf = Fdopen(fd, "w+")) == NULL) {
407 if (fd != -1)
408 (void)close(fd);
409 warn("%s", mailtempname);
410 goto err;
411 }
412 (void)rm(mailtempname);
413
414 /*
415 * If we are going to prompt for a subject,
416 * refrain from printing a newline after
417 * the headers (since some people mind).
418 */
419 t = GTO|GSUBJECT|GCC|GNL|GSMOPTS;
420 getsub = 0;
421 if (hp->h_subject == NULL && value(ENAME_INTERACTIVE) != NULL &&
422 (value(ENAME_ASK) != NULL || value(ENAME_ASKSUB) != NULL))
423 t &= ~GNL, getsub++;
424 if (printheaders) {
425 (void)puthead(hp, stdout, t);
426 (void)fflush(stdout);
427 }
428 if ((cp = value(ENAME_ESCAPE)) != NULL)
429 escape = *cp;
430 else
431 escape = ESCAPE;
432 hadintr = 0; /* static - no longjmp problem */
433 if (!setjmp(colljmp)) {
434 if (getsub)
435 (void)grabh(hp, GSUBJECT);
436 } else {
437 /*
438 * Come here for printing the after-signal message.
439 * Duplicate messages won't be printed because
440 * the write is aborted if we get a SIGTTOU.
441 */
442 cont:
443 if (hadintr) {
444 (void)fflush(stdout);
445 (void)fprintf(stderr,
446 "\n(Interrupt -- one more to kill letter)\n");
447 } else {
448 (void)printf("(continue)\n");
449 (void)fflush(stdout);
450 }
451 }
452 eofcount = 0; /* reset after possible longjmp */
453 longline = 0; /* reset after possible longjmp */
454 for (;;) {
455 colljmp_p = 1;
456 c = mail_readline(stdin, linebuf, LINESIZE);
457 colljmp_p = 0;
458 #ifdef USE_EDITLINE
459 if (c < 0) {
460 char *p;
461 if (value(ENAME_INTERACTIVE) != NULL &&
462 (p = value(ENAME_IGNOREEOF)) != NULL &&
463 ++eofcount < (*p == 0 ? 25 : atoi(p))) {
464 (void)printf("Use \".\" to terminate letter\n");
465 continue;
466 }
467 break;
468 }
469 #else
470 if (c < 0) {
471 if (value(ENAME_INTERACTIVE) != NULL &&
472 value(ENAME_IGNOREEOF) != NULL && ++eofcount < 25) {
473 (void)printf("Use \".\" to terminate letter\n");
474 continue;
475 }
476 break;
477 }
478 #endif
479 lastlong = longline;
480 longline = c == LINESIZE-1;
481 eofcount = 0;
482 hadintr = 0;
483 if (linebuf[0] == '.' && linebuf[1] == '\0' &&
484 value(ENAME_INTERACTIVE) != NULL && !lastlong &&
485 (value(ENAME_DOT) != NULL || value(ENAME_IGNOREEOF) != NULL))
486 break;
487 if (linebuf[0] != escape || value(ENAME_INTERACTIVE) == NULL ||
488 lastlong) {
489 if (putline(collf, linebuf, !longline) < 0)
490 goto err;
491 continue;
492 }
493 c = linebuf[1];
494 switch (c) {
495 default:
496 /*
497 * On double escape, just send the single one.
498 * Otherwise, it's an error.
499 */
500 if (c == escape) {
501 if (putline(collf, &linebuf[1], !longline) < 0)
502 goto err;
503 else
504 break;
505 }
506 (void)printf("Unknown tilde escape.\n");
507 break;
508 #ifdef MIME_SUPPORT
509 case '@':
510 hp->h_attach = mime_attach_files(hp->h_attach, &linebuf[2]);
511 break;
512 #endif
513 case 'C':
514 /*
515 * Dump core.
516 */
517 (void)core(NULL);
518 break;
519 case '!':
520 /*
521 * Shell escape, send the balance of the
522 * line to sh -c.
523 */
524 (void)shell(&linebuf[2]);
525 break;
526 case ':':
527 case '_':
528 /*
529 * Escape to command mode, but be nice!
530 */
531 (void)execute(&linebuf[2], 1);
532 goto cont;
533 case '.':
534 /*
535 * Simulate end of file on input.
536 */
537 goto out;
538 case 'q':
539 /*
540 * Force a quit of sending mail.
541 * Act like an interrupt happened.
542 */
543 hadintr++;
544 collint(SIGINT);
545 exit(1);
546 /*NOTREACHED*/
547
548 case 'x': /* exit, do not save in dead.letter */
549 goto err;
550
551 case 'h':
552 /*
553 * Grab a bunch of headers.
554 */
555 (void)grabh(hp, GTO|GSUBJECT|GCC|GBCC|GSMOPTS);
556 goto cont;
557 case 't':
558 /*
559 * Add to the To list.
560 */
561 hp->h_to = cat(hp->h_to, extract(&linebuf[2], GTO));
562 break;
563 case 's':
564 /*
565 * Set the Subject list.
566 */
567 cp = &linebuf[2];
568 while (isspace((unsigned char)*cp))
569 cp++;
570 hp->h_subject = savestr(cp);
571 break;
572 case 'c':
573 /*
574 * Add to the CC list.
575 */
576 hp->h_cc = cat(hp->h_cc, extract(&linebuf[2], GCC));
577 break;
578 case 'b':
579 /*
580 * Add stuff to blind carbon copies list.
581 */
582 hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC));
583 break;
584 case 'i':
585 case 'A':
586 case 'a':
587 /*
588 * Insert named variable in message
589 */
590
591 switch(c) {
592 case 'i':
593 cp = &linebuf[2];
594 while(isspace((unsigned char) *cp))
595 cp++;
596
597 break;
598 case 'a':
599 cp = "sign";
600 break;
601 case 'A':
602 cp = "Sign";
603 break;
604 default:
605 goto err;
606 }
607
608 if (*cp && (cp = value(cp)) != NULL) {
609 (void)printf("%s\n", cp);
610 if (putline(collf, cp, 1) < 0)
611 goto err;
612 }
613
614 break;
615
616 case 'd':
617 (void)strcpy(linebuf + 2, getdeadletter());
618 /* FALLTHROUGH */
619 case 'r':
620 case '<':
621 /*
622 * Invoke a file:
623 * Search for the file name,
624 * then open it and copy the contents to collf.
625 */
626 cp = &linebuf[2];
627 while (isspace((unsigned char)*cp))
628 cp++;
629 if (*cp == '\0') {
630 (void)printf("Interpolate what file?\n");
631 break;
632 }
633
634 cp = expand(cp);
635 if (cp == NULL)
636 break;
637
638 if (*cp == '!') { /* insert stdout of command */
639 const char *shellcmd;
640 int nullfd;
641 int rc2;
642
643 if ((nullfd = open("/dev/null", O_RDONLY, 0)) == -1) {
644 warn("/dev/null");
645 break;
646 }
647
648 (void)snprintf(tempname, sizeof(tempname),
649 "%s/mail.ReXXXXXXXXXX", tmpdir);
650 if ((fd = mkstemp(tempname)) == -1 ||
651 (fbuf = Fdopen(fd, "w+")) == NULL) {
652 if (fd != -1)
653 (void)close(fd);
654 warn("%s", tempname);
655 break;
656 }
657 (void)unlink(tempname);
658
659 if ((shellcmd = value(ENAME_SHELL)) == NULL)
660 shellcmd = _PATH_CSHELL;
661
662 rc2 = run_command(shellcmd, 0, nullfd, fileno(fbuf), "-c", cp + 1, NULL);
663
664 (void)close(nullfd);
665
666 if (rc2 < 0) {
667 (void)Fclose(fbuf);
668 break;
669 }
670
671 if (fsize(fbuf) == 0) {
672 (void)fprintf(stderr, "No bytes from command \"%s\"\n", cp + 1);
673 (void)Fclose(fbuf);
674 break;
675 }
676
677 rewind(fbuf);
678 }
679 else if (isdir(cp)) {
680 (void)printf("%s: Directory\n", cp);
681 break;
682 }
683 else if ((fbuf = Fopen(cp, "r")) == NULL) {
684 warn("%s", cp);
685 break;
686 }
687 (void)printf("\"%s\" ", cp);
688 (void)fflush(stdout);
689 lc = 0;
690 cc = 0;
691 while ((rc = mail_readline(fbuf, linebuf, LINESIZE)) >= 0) {
692 if (rc != LINESIZE-1) lc++;
693 if ((t = putline(collf, linebuf,
694 rc != LINESIZE-1)) < 0) {
695 (void)Fclose(fbuf);
696 goto err;
697 }
698 cc += t;
699 }
700 (void)Fclose(fbuf);
701 (void)printf("%d/%d\n", lc, cc);
702 break;
703 case 'w':
704 /*
705 * Write the message on a file.
706 */
707 cp = &linebuf[2];
708 while (*cp == ' ' || *cp == '\t')
709 cp++;
710 if (*cp == '\0') {
711 (void)fprintf(stderr, "Write what file!?\n");
712 break;
713 }
714 if ((cp = expand(cp)) == NULL)
715 break;
716 rewind(collf);
717 (void)exwrite(cp, collf, 1);
718 break;
719 case 'm':
720 case 'M':
721 case 'f':
722 case 'F':
723 /*
724 * Interpolate the named messages, if we
725 * are in receiving mail mode. Does the
726 * standard list processing garbage.
727 * If ~f is given, we don't shift over.
728 */
729 if (forward(linebuf + 2, collf, mailtempname, c) < 0)
730 goto err;
731 goto cont;
732 case '?':
733 if ((fbuf = Fopen(_PATH_TILDE, "r")) == NULL) {
734 warn(_PATH_TILDE);
735 break;
736 }
737 while ((t = getc(fbuf)) != EOF)
738 (void)putchar(t);
739 (void)Fclose(fbuf);
740 break;
741 case 'p':
742 /*
743 * Print out the current state of the
744 * message without altering anything.
745 */
746 rewind(collf);
747 (void)printf("-------\nMessage contains:\n");
748 (void)puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL);
749 while ((t = getc(collf)) != EOF)
750 (void)putchar(t);
751 goto cont;
752 case '|':
753 /*
754 * Pipe message through command.
755 * Collect output as new message.
756 */
757 rewind(collf);
758 mespipe(collf, &linebuf[2]);
759 goto cont;
760 case 'v':
761 case 'e':
762 /*
763 * Edit the current message.
764 * 'e' means to use EDITOR
765 * 'v' means to use VISUAL
766 */
767 rewind(collf);
768 mesedit(collf, c);
769 goto cont;
770 }
771 }
772 goto out;
773 err:
774 if (collf != NULL) {
775 (void)Fclose(collf);
776 collf = NULL;
777 }
778 out:
779 if (collf != NULL)
780 rewind(collf);
781 noreset--;
782 (void)sigprocmask(SIG_BLOCK, &nset, NULL);
783 (void)signal(SIGINT, saveint);
784 (void)signal(SIGHUP, savehup);
785 (void)signal(SIGTSTP, savetstp);
786 (void)signal(SIGTTOU, savettou);
787 (void)signal(SIGTTIN, savettin);
788 (void)sigprocmask(SIG_UNBLOCK, &nset, NULL);
789 return collf;
790 }
791