xref: /original-bsd/usr.bin/uucp/libuu/xqt.c (revision cef711d2)
1 /*-
2  * Copyright (c) 1985, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)xqt.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 #include <signal.h>
13 #include "uucp.h"
14 
15 int LocalOnly = 0;
16 
17 /*LINTLIBRARY*/
18 
19 /*
20  *	start up uucico for rmtname
21  *
22  *	return codes:  none
23  */
24 
25 #ifdef	VMS
26 #define	fork	vfork
27 #endif VMS
28 
29 xuucico(rmtname)
30 char *rmtname;
31 {
32 	if (fork() == 0) {
33 		/*  start uucico for rmtname system  */
34 		char opt[100];
35 		close(0);
36 		close(1);
37 		close(2);
38 		open(DEVNULL, 0);
39 		open(DEVNULL, 1);
40 		open(DEVNULL, 1);
41 		signal(SIGINT, SIG_IGN);
42 		signal(SIGHUP, SIG_IGN);
43 		signal(SIGQUIT, SIG_IGN);
44 		signal(SIGKILL, SIG_IGN);
45 		if (rmtname[0] != '\0')
46 			sprintf(opt, "-s%s", rmtname);
47 		else
48 			opt[0] = '\0';
49 #ifndef	VMS
50 		if (LocalOnly)
51 			execl(UUCICO, "uucico", "-r1", "-L", opt, (char *)0);
52 		else
53 			execl(UUCICO, "uucico", "-r1", opt, (char *)0);
54 #else	VMS
55 		/* Under VMS/EUNICE release the batch job */
56 		if (LocalOnly)
57 			execl(STARTUUCP, "startuucp", "uucico", "-r1", "-L", opt, (char *)0);
58 		else
59 			execl(STARTUUCP, "startuucp", "uucico", "-r1", opt, (char *)0);
60 #endif	VMS
61 		exit(100);
62 	}
63 #ifdef	VMS
64 	while(wait(0) != -1)
65 		;	/* Wait for it to finish!! */
66 #endif	VMS
67 	return;
68 }
69 
70 /*
71  *	start up uuxqt
72  *
73  *	return codes:  none
74  */
75 xuuxqt()
76 {
77 	if (fork() == 0) {
78 		/*  start uuxqt  */
79 		close(0);
80 		close(1);
81 		close(2);
82 		open(DEVNULL, 2);
83 		open(DEVNULL, 2);
84 		open(DEVNULL, 2);
85 		signal(SIGINT, SIG_IGN);
86 		signal(SIGHUP, SIG_IGN);
87 		signal(SIGQUIT, SIG_IGN);
88 		signal(SIGKILL, SIG_IGN);
89 		execl(UUXQT, "uuxqt",  (char *)0);
90 		exit(100);
91 	}
92 }
93 
94 xuucp(str)
95 char *str;
96 {
97 	char text[300];
98 	if (fork() == 0) {
99 		/*  start uucp  */
100 		close(0);
101 		close(1);
102 		close(2);
103 		open(DEVNULL, 0);
104 		open(DEVNULL, 1);
105 		open(DEVNULL, 1);
106 		signal(SIGINT, SIG_IGN);
107 		signal(SIGHUP, SIG_IGN);
108 		signal(SIGQUIT, SIG_IGN);
109 		signal(SIGKILL, SIG_IGN);
110 		sprintf(text, "%s -r %s", UUCP, str);
111 		execl(SHELL, "sh", "-c", text, CNULL);
112 		exit(100);
113 	}
114 	sleep(15);	/* Give uucp chance to finish */
115 }
116