Can a trap survive an exec /bin/sh?
John Takao Collier
takao at ihu1h.UUCP
Sat Sep 14 01:24:33 AEST 1985
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
More information about the Comp.unix
mailing list