Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!bloom-beacon!mgm.mit.edu!wolfgang From: wolfgang@mgm.mit.edu (Wolfgang Rupprecht) Newsgroups: comp.unix.wizards Subject: Re: DTR failure on DZ-11 ports Keywords: DTR, DZ-11, 4.3 BSD, UNIX Message-ID: <2645@bloom-beacon.MIT.EDU> Date: 29 Jan 88 16:51:25 GMT References: <1507@uoregon.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: wolfgang@mgm.mit.edu (Wolfgang Rupprecht) Organization: Freelance Software Consultant, Cambridge, Ma. Lines: 113 In article <1507@uoregon.UUCP> johnz@uoregon.UUCP (John Bruce Zuckerman) writes: >We are running several VAX 11/750's with attached DZ-11 serial >interfaces. On very infrequent occasions, the DTR signal fails to be >raised on one or more of the DZ-11 ports. This prevents users from >logging in on the affected ports. I have seen this too. In my case it was always due to a process running in the background with that port as the controling tty. I guess that the tty never really got closed and getty couldn't run and raise the DTR line. I now run background jobs (that I want to start and forget) with no controlling tty and no open tty devices. This has solved the stuck port problem for me. Appended to the end of this message is a hack program bgdo.c that runs an arbitrary unix command in the *far* background with no controlling tty, and as a child of init. -- Wolfgang Rupprecht ARPA: wolfgang@mgm.mit.edu (IP 18.82.0.114) Freelance Consultant UUCP: mit-eddie!mgm.mit.edu!wolfgang Boston, Ma. VOICE: Hey_Wolfgang!_(617)_267-4365 /****************************************************************************** * * * File: bgdo.c * * Author: Wolfgang Rupprecht * * Created: Wed Jan 27 10:19:07 EST 1988 * * Contents: run a program in the FAR background. * * the process gets orpahned, and adopted by init * * and the controlling tty gets disowned. * * * * Copyright (c) 1988 Wolfgang Rupprecht. * * Free use of this program is permitted, subject to the * * conditions that this header and copyright notice remain * * intact, and that this source file is freely available. * * * * $Log$ * ******************************************************************************/ #include #include #include #include char *progname; void gripe(), fatal(); main(argc, argv) int argc; char **argv; { char buf[128], *cp; int status; if (argc < 2) /* no args, done */ exit(0); cp = rindex (argv[0], '/'); /* find basename of this command */ progname = cp ? (cp+1) : argv[0]; cp = rindex (argv[1], '/'); /* find basename of program to be run */ cp = cp ? (cp+1) : argv[1]; (void) sprintf(buf, "%s.log", cp); /* tell'em where to find their output */ fprintf(stderr, "Sending output to %s\n", buf); _cleanup(); /* close ALL files */ (void) open("/dev/tty", O_RDONLY, 0); /* release controlling tty */ (void) ioctl(0, TIOCNOTTY, (char *) 0); (void) close(0); (void) fopen("/dev/null", "r"); /* open new stdin */ (void) fopen(buf, "w"); /* open new stdout */ (void) dup(1); /* dup it to new stderr */ (void) fdopen(2, "w"); /* and open it proper */ if ((status = fork()) > 0) /* parent */ exit(0); if (status < 0) /* fork failed */ fatal("first fork"); if ((status = fork()) > 0) /* parent */ exit(0); if (status < 0) /* fork failed */ fatal("second fork"); if (setpgrp(0, 1) < 0) gripe("setpgrp"); /* fatal ?? */ execvp(argv[1], &argv[1]); /* finally, exec the requested command */ fatal(argv[1]); /* what, we're still here? There is an error... gripe and quit. */ } void gripe(cp) char *cp; { char buf[128]; (void) sprintf(buf, "%s: %s", progname, cp); perror(buf); } void fatal(cp) char *cp; { gripe(cp); exit(-1); } Wolfgang Rupprecht ARPA: wolfgang@mgm.mit.edu (IP 18.82.0.114) Freelance Consultant UUCP: mit-eddie!mgm.mit.edu!wolfgang Boston, Ma. VOICE: Hey_Wolfgang!_(617)_267-4365