1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
$NetBSD: patch-cj,v 1.4 2017/12/12 20:42:41 hauke Exp $
--- lib/libxview/ttysw/tty_init.c.orig 1993-06-29 05:17:19.000000000 +0000
+++ lib/libxview/ttysw/tty_init.c
@@ -14,6 +14,7 @@ static char sccsid[] = "@(#)tty_init
* Ttysw initialization, destruction and error procedures
*/
+#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -80,9 +81,11 @@ static char sccsid[] = "@(#)tty_init
#endif
-extern char *strncpy();
-extern char *strcpy();
+#if (defined(BSD) && (BSD >= 199306))
+extern off_t lseek();
+#else
extern long lseek();
+#endif
char *textsw_checkpoint_undo();
/* static */ void ttysw_parseargs();
@@ -106,6 +109,7 @@ Xv_private char *xv_font_monospace();
extern int ttysel_use_seln_service;
+static int ttyinit();
struct ttysw_createoptions {
int becomeconsole; /* be the console */
@@ -432,10 +436,8 @@ ttysw_fork_it(ttysw0, argv, wfd)
char appname[20];
char *p;
unsigned ttysw_error_sleep = 1;
-#ifndef SVR4
- struct sigvec vec, ovec;
-#else
struct sigaction vec, ovec;
+#ifdef SVR4
extern char *ptsname();
#define BSD_TTY_COMPAT /* yank this if csh ever gets ported properly */
@@ -461,27 +463,6 @@ ttysw_fork_it(ttysw0, argv, wfd)
}
/* Set up the child characteristics */
-#ifndef SVR4 /* SunOS4.x code */
- vec.sv_handler = SIG_DFL;
- vec.sv_mask = vec.sv_onstack = 0;
- sigvec(SIGWINCH, &vec, 0);
- /*
- * Become session leader, change process group of child
- * process (me at this point in code) so
- * its signal stuff doesn't affect the terminal emulator.
- */
- setsid();
- vec.sv_handler = SIG_IGN;
- vec.sv_mask = vec.sv_onstack = 0;
- sigvec(SIGTTOU, &vec, &ovec);
-
- close(ttysw->ttysw_tty);
-
- /* Make the following file descriptor be my controlling terminal */
- ttysw->ttysw_tty = open("/dev/tty", O_RDWR, 0); /* open master tty* */
- sigvec(SIGTTOU, &ovec, 0);
-
-#else /* SVR4 code */
vec.sa_handler = SIG_DFL;
sigemptyset(&vec.sa_mask);
vec.sa_flags = SA_RESTART;
@@ -497,13 +478,19 @@ ttysw_fork_it(ttysw0, argv, wfd)
vec.sa_flags = SA_RESTART;
sigaction(SIGTTOU, &vec, &ovec);
+#ifndef SVR4 /* SunOS4.x code */
+ close(ttysw->ttysw_tty);
+
+ /* Make the following file descriptor be my controlling terminal */
+ ttysw->ttysw_tty = open("/dev/tty", O_RDWR, 0); /* open master tty* */
+#else /* SVR4 code */
if (unlockpt(ttysw->ttysw_pty) == -1)
perror("unlockpt (2)");
if ((ttysw->ttysw_tty = open(ptsname(ttysw->ttysw_pty),O_RDWR))<0)
return -1;
+#endif /* SVR4 */
sigaction(SIGTTOU, &ovec, (struct sigaction *) 0);
-#endif /* SVR4 */
/*
* Initialize file descriptors. Connections to servers are marked as
@@ -518,6 +505,9 @@ ttysw_fork_it(ttysw0, argv, wfd)
(void) dup2(ttysw->ttysw_tty, 2);
(void) close(ttysw->ttysw_tty);
+#if (defined(BSD) && (BSD >= 199103))
+ (void) ioctl(0, TIOCSCTTY, NULL);
+#endif
if (*argv == (char *) NULL || strcmp("-c", *argv) == 0) {
/* Process arg list */
int argc;
@@ -955,7 +945,11 @@ updateutmp(username, ttyslotuse, ttyfd)
struct utmpx utmp;
#endif
struct passwd *passwdent;
+#if !(defined(BSD) && (BSD >= 199103))
extern struct passwd *getpwuid();
+#else
+ struct passwd *getpwuid __P((uid_t));
+#endif
int f;
char *ttyn;
extern char *ttyname();
@@ -1007,13 +1001,22 @@ updateutmp(username, ttyslotuse, ttyfd)
XV_MSG("Add tty[qrs][0-f] to /etc/ttys file.\n"));
return (0);
}
+#if !(defined(BSD) && (BSD >= 199103))
if ((f = open("/etc/utmp", 1)) >= 0) {
+#else
+ if ((f = open(_PATH_UTMP, 1)) >= 0) {
+#endif
(void) lseek(f, (long) (ttyslotuse * sizeof(utmp)), 0);
(void) write(f, (char *) &utmp, sizeof(utmp));
(void) close(f);
} else {
(void) fprintf(stderr,
+#if !(defined(BSD) && (BSD >= 199103))
XV_MSG("make sure that you can write /etc/utmp!\n"));
+#else
+ XV_MSG("make sure that you can write "));
+ (void) fprintf(stderr, "%s!\n", _PATH_UTMP);
+#endif
return (0);
}
return (ttyslotuse);
|