Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site ihu1h.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ihu1h!takao From: takao@ihu1h.UUCP (John Takao Collier) Newsgroups: net.unix Subject: Can a trap survive an exec /bin/sh? Message-ID: <668@ihu1h.UUCP> Date: Fri, 13-Sep-85 11:24:33 EDT Article-I.D.: ihu1h.668 Posted: Fri Sep 13 11:24:33 1985 Date-Received: Sat, 14-Sep-85 06:31:57 EDT Distribution: na Organization: AT&T Bell Laboratories Lines: 33 Is there a way to get a trap to survive the exec of the shell? What I want to do is set a trap, exec a shell, continue on with an interactive session in the exec'ed shell, and have the trap turned on in the exec'ed shell. This comes in handy if you want to set a trap in a .profile, but want to exec a new shell in the .profile. For example, if the following commands are invoked: trap 'echo bye' 0 exec /bin/sh the trap disappears. I have tried various parameters to the shell, such as "-c" and "-i", but these experiments have failed, e.g.: exec /bin/sh -c 'trap "echo bye" 0' will exec the shell, read the string specified by the the "-c" parameter, reads the trap, then exits the exec'ed shell. I do not want to exit the shell. If you have a solution, be it elegant or ugly, I would very much like to see it. Thanks. -- --- John Takao Collier ..ihnp4!ihu1h!takao 1-312-979-3278 AT&T Bell Laboratories, Naperville-Wheaton Road, Naperville, IL 60566