Commit | Line | Data |
---|---|---|
051b1e55 DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
05862919 | 7 | #ifndef lint |
051b1e55 DF |
8 | static char sccsid[] = "@(#)hunt.c 5.1 (Berkeley) %G%"; |
9 | #endif not lint | |
60d5f7dd | 10 | |
05862919 | 11 | #include "tip.h" |
60d5f7dd BJ |
12 | |
13 | extern char *getremote(); | |
14 | extern char *rindex(); | |
15 | ||
05862919 SL |
16 | static jmp_buf deadline; |
17 | static int deadfl; | |
60d5f7dd BJ |
18 | |
19 | dead() | |
20 | { | |
05862919 | 21 | |
60d5f7dd | 22 | deadfl = 1; |
05862919 | 23 | longjmp(deadline, 1); |
60d5f7dd BJ |
24 | } |
25 | ||
26 | hunt(name) | |
d8feebc2 | 27 | char *name; |
60d5f7dd BJ |
28 | { |
29 | register char *cp; | |
05862919 | 30 | int (*f)(); |
60d5f7dd | 31 | |
05862919 | 32 | f = signal(SIGALRM, dead); |
60d5f7dd | 33 | deadfl = 0; |
3f48242d | 34 | while (cp = getremote(name)) { |
60d5f7dd BJ |
35 | uucplock = rindex(cp, '/')+1; |
36 | if (mlock(uucplock) < 0) { | |
37 | delock(uucplock); | |
38 | continue; | |
39 | } | |
f0211bf2 | 40 | /* |
6b46907f RC |
41 | * Straight through call units, such as the BIZCOMP, |
42 | * VADIC and the DF, must indicate they're hardwired in | |
f0211bf2 SL |
43 | * order to get an open file descriptor placed in FD. |
44 | * Otherwise, as for a DN-11, the open will have to | |
45 | * be done in the "open" routine. | |
46 | */ | |
47 | if (!HW) | |
48 | break; | |
05862919 SL |
49 | if (setjmp(deadline) == 0) { |
50 | alarm(10); | |
51 | FD = open(cp, O_RDWR); | |
60d5f7dd BJ |
52 | } |
53 | alarm(0); | |
274c3d56 MK |
54 | if (FD < 0) { |
55 | perror(cp); | |
56 | deadfl = 1; | |
57 | } | |
05862919 SL |
58 | if (!deadfl) { |
59 | ioctl(FD, TIOCEXCL, 0); | |
60 | ioctl(FD, TIOCHPCL, 0); | |
61 | signal(SIGALRM, SIG_DFL); | |
62 | return ((int)cp); | |
63 | } | |
673be859 | 64 | delock(uucplock); |
60d5f7dd | 65 | } |
05862919 | 66 | signal(SIGALRM, f); |
3f48242d | 67 | return (deadfl ? -1 : (int)cp); |
60d5f7dd | 68 | } |