Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!mcdchg!usenet From: usenet@mcdchg.UUCP Newsgroups: mod.os.unix Subject: How does close() make dup() work in getty?? Message-ID: <233@mcdchg.UUCP> Date: Fri, 13-Mar-87 10:11:52 EST Article-I.D.: mcdchg.233 Posted: Fri Mar 13 10:11:52 1987 Date-Received: Sat, 14-Mar-87 07:06:59 EST Sender: usenet@mcdchg.UUCP Organization: Univ. of Central Florida, Orlando Lines: 46 Keywords: close dup getty /dev/tty Approved: usenet@falkor.UUCP I recently wrote a new getty for a RT built around curses. My question is about why one version works and another not. The following code out lines the differences in the two versions. Version 1 does not work while Version 2 does. Version 1. main(tty) char *tty; /* tty to use */ { set_ioctl(); /* put in known mode */ close(0); close(1); close(2); dup(dup(open(tty,2))); write_utmp(tty); /* do utmp stuff */ get_logid(logid); /* prompt for logid */ execle("/bin/login",logid,NULL); } Version 2. main(tty) char *tty; /* tty to use */ { set_ioctl(); /* put in known mode */ close(0); close(1); open(tty,2); close(2); dup(0); dup(1); write_utmp(tty); /* do utmp stuff */ get_logid(logid); /* prompt for logid */ execle("/bin/login",logid,NULL); } Does close() cause something to settle that dup() needes from the open()? The problem with Version one is that /dev/tty does not get attached to the control group. Any idea's that might explain this mystery would be greatly appreciated!! -- Larry Baird Dept. of Computer Science uucp: {ihnp4!decvax,peora}!ucf-cs!baird University of Central Florida Orlando, FL 32816