dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / tip / hunt.c
blobf6280c2834d724c4dfd763920b65bf31d46b3926
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /*
7 * Copyright (c) 1983 Regents of the University of California.
8 * All rights reserved. The Berkeley software License Agreement
9 * specifies the terms and conditions for redistribution.
12 #pragma ident "%Z%%M% %I% %E% SMI"
14 #include "tip.h"
16 static sigjmp_buf deadline;
17 static int deadfl;
19 void
20 dead(void)
23 deadfl = 1;
24 siglongjmp(deadline, 1);
27 int
28 hunt(char *name)
30 char *cp;
31 sig_handler_t f;
33 f = signal(SIGALRM, (sig_handler_t)dead);
34 while (cp = getremote(name)) {
35 deadfl = 0;
36 uucplock = cp;
37 if (tip_mlock(uucplock) < 0) {
38 delock(uucplock);
39 continue;
42 * Straight through call units, such as the BIZCOMP,
43 * VADIC and the DF, must indicate they're hardwired in
44 * order to get an open file descriptor placed in FD.
45 * Otherwise, as for a DN-11, the open will have to
46 * be done in the "open" routine.
48 if (!HW)
49 break;
50 if (sigsetjmp(deadline, 1) == 0) {
51 (void) alarm(10);
52 if (!trusted_device)
53 userperm();
54 errno = 0;
55 if ((FD = open(cp, O_RDWR)) < 0 && errno != EBUSY) {
56 (void) fprintf(stderr, "tip: ");
57 perror(cp);
59 if (!trusted_device)
60 myperm();
61 if (FD >= 0 && !isatty(FD)) {
62 (void) fprintf(stderr, "tip: %s: not a tty\n",
63 cp);
64 (void) close(FD);
65 FD = -1;
68 (void) alarm(0);
69 if (!deadfl && FD >= 0) {
70 struct termios t;
72 (void) ioctl(FD, TCGETS, &t);
73 t.c_cflag |= XCLUDE|HUPCL;
74 (void) ioctl(FD, TCSETSF, &t);
75 (void) signal(SIGALRM, f);
76 return ((int)cp);
78 delock(uucplock);
80 (void) signal(SIGALRM, f);
81 return (deadfl ? -1 : (int)cp);