raz / test / run / Execve.raz

15 lines · 617 B · raw · history · last change 35fa926d

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. *)
4module Execve;
5import Sys;
6
7proc main*: INT;
8begin
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"]);
13end;
14
15end Execve.