Commit | Line | Data |
---|---|---|
ad787160 C |
1 | #ifndef lint |
2 | static char sccsid[] = "@(#)detach.c 2.2 88/08/10 4.0 RPCSRC"; | |
3 | #endif | |
cfbe44a4 KM |
4 | /* |
5 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for | |
6 | * unrestricted use provided that this legend is included on all tape | |
7 | * media and as a part of the software program in whole or part. Users | |
8 | * may copy or modify Sun RPC without charge, but are not authorized | |
9 | * to license or distribute it to anyone else except as part of a product or | |
10 | * program developed by the user. | |
11 | * | |
12 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE | |
13 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR | |
14 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | |
15 | * | |
16 | * Sun RPC is provided with no support and without any obligation on the | |
17 | * part of Sun Microsystems, Inc. to assist in its use, correction, | |
18 | * modification or enhancement. | |
19 | * | |
20 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE | |
21 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC | |
22 | * OR ANY PART THEREOF. | |
23 | * | |
24 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue | |
25 | * or profits or other special, indirect and consequential damages, even if | |
26 | * Sun has been advised of the possibility of such damages. | |
27 | * | |
28 | * Sun Microsystems, Inc. | |
29 | * 2550 Garcia Avenue | |
30 | * Mountain View, California 94043 | |
31 | */ | |
32 | ||
33 | /* | |
cfbe44a4 KM |
34 | * Copyright (C) 1986, Sun Microsystems, Inc. |
35 | */ | |
36 | ||
ad787160 C |
37 | #include <sys/ioctl.h> |
38 | #include <fcntl.h> | |
cfbe44a4 | 39 | |
ad787160 C |
40 | /* |
41 | * detach from tty | |
42 | */ | |
43 | detachfromtty() | |
44 | { | |
45 | int tt; | |
cfbe44a4 | 46 | |
ad787160 C |
47 | close(0); |
48 | close(1); | |
49 | close(2); | |
50 | switch (fork()) { | |
51 | case -1: | |
52 | perror("fork"); | |
53 | break; | |
54 | case 0: | |
55 | break; | |
56 | default: | |
57 | exit(0); | |
58 | } | |
59 | tt = open("/dev/tty", O_RDWR); | |
60 | if (tt > 0) { | |
61 | ioctl(tt, TIOCNOTTY, 0); | |
62 | close(tt); | |
63 | } | |
64 | (void)open("/dev/null", O_RDWR, 0); | |
65 | dup(0); | |
66 | dup(0); | |
67 | } | |
68 | ||
cfbe44a4 | 69 |