| 1 | (* Sys.execve: this program replaced by sh, found by no search, |
| 2 | with the environment it is given and no other, a signal ignored |
| 3 | still ignored and one handled back to what it does at first. *) |
| 4 | module Execve; |
| 5 | import Sys; |
| 6 | |
| 7 | proc main*: INT; |
| 8 | begin |
| 9 | if (Sys.ignore(1, true) # 0) or (Sys.handle(10) # 0) then return 1; end; (* SIGHUP, SIGUSR1 *) |
| 10 | return Sys.execve("/bin/sh", ["sh", "-c", |
| 11 | "echo $X ${HOME-none}; while read k v; do case $k in SigIgn:) echo ignored $((0x$v & 1));; SigCgt:) echo caught $((0x$v >> 9 & 1));; esac; done </proc/self/status; exit 5"], |
| 12 | ["X=only"]); |
| 13 | end; |
| 14 | |
| 15 | end Execve. |