xref: /titanic_50/usr/src/cmd/ttymon/tmglobal.c (revision e5dcf7beb7c949f9234713d5818b581ec3825443)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 
33 
34 #include <stdio.h>
35 #include <poll.h>
36 #include <signal.h>
37 #include <sys/resource.h>
38 #include <sac.h>
39 #include "tmstruct.h"
40 #include "ttymon.h"
41 
42 /*
43  *	global fd and fp
44  */
45 FILE	*Logfp = NULL;		/* for log file			*/
46 int	Lckfd;			/* for pid file			*/
47 int	Sfd, Pfd;		/* for sacpipe and pmpipe 	*/
48 int	PCpipe[2];		/* pipe between Parent & Children */
49 #ifdef	DEBUG
50 FILE	*Debugfp = NULL;	/* for debug file		*/
51 #endif
52 
53 char	State = PM_STARTING;	/* current state			*/
54 char	*Istate;		/* initial state			*/
55 char	*Tag;			/* port monitor tag			*/
56 int	Maxfiles;		/* Max number of open files		*/
57 int	Maxfds;			/* Max no of devices ttymon can monitor */
58 
59 int	Reread_flag = FALSE;	/* reread pmtab flag			*/
60 
61 int	Retry;			/* retry open_device flag		*/
62 
63 struct  pmtab *PMtab = NULL;	/* head pointer to pmtab linked list 	*/
64 int	Nentries = 0;		/* # of entries in pmtab linked list	*/
65 
66 struct  Gdef Gdef[MAXDEFS];	/* array to hold entries in /etc/ttydefs */
67 int	Ndefs = 0;		/* highest index to Gdef that was used   */
68 long	Mtime = 0;		/* last modification time of ttydefs	 */
69 
70 struct pollfd *Pollp;		/* ptr to an array of poll struct 	 */
71 int	Npollfd;		/* size of the pollfd array		 */
72 
73 struct Gdef DEFAULT = {		/* default terminal settings	*/
74 	"default",
75 	"9600",
76 	"9600 sane",
77 	0,
78 	/*
79 	 * next label is set to 4800 so we can start searching ttydefs.
80 	 * if 4800 is not in ttydefs, we will loop back to use DEFAULT
81 	 */
82 	"4800"
83 };
84 
85 uid_t	Uucp_uid = 5;		/* owner's uid for bi-directional ports	*/
86 gid_t	Tty_gid = 7;		/* group id for all tty devices		*/
87 
88 /*
89  * Nlocked - 	number of ports that are either locked or have active
90  *		sessions not under this ttymon.
91  */
92 int	Nlocked = 0;
93 
94 /* original rlimit value */
95 struct	rlimit	Rlimit;
96 
97 /*
98  * places to remember original signal dispositions and masks
99  */
100 
101 sigset_t	Origmask;		/* original signal mask */
102 struct	sigaction	Sigalrm;	/* SIGALRM */
103 struct	sigaction	Sigcld;		/* SIGCLD */
104 struct	sigaction	Sigint;		/* SIGINT */
105 struct	sigaction	Sigpoll;	/* SIGPOLL */
106 struct	sigaction	Sigterm;	/* SIGTERM */
107 #ifdef	DEBUG
108 struct	sigaction	Sigusr1;	/* SIGUSR1 */
109 struct	sigaction	Sigusr2;	/* SIGUSR2 */
110 #endif
111 
112 struct strbuf *peek_ptr;
113 
114 int Logmaxsz = 1000000; /* Log Max Size */
115 
116 int Splflag = 0; /* serialize Log file manipulation */
117