mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 17:25:33 +00:00
Rename signal actions to reflect the POSIX naming
Use the same names for signal actions as the C headers. Since the actions are atoms, the names are lower cased. Invent the name 'sig_catch' to denote signals that are caught and passed to the erlang side as messages. Add the 'sig_' prefix to all the actions to avoid quoting 'catch', since it is a reserved keyword.
This commit is contained in:
14
README.md
14
README.md
@@ -432,7 +432,7 @@ probably confuse the process.
|
||||
event(Drv, Pids) -> term()
|
||||
|
||||
event/1,2 is used to retrieve async messages returned from the
|
||||
port, such as trapped signals, the exit status or the termination
|
||||
port, such as caught signals, the exit status or the termination
|
||||
signal.
|
||||
|
||||
execve(Drv, Arg0, [Arg0, Args], Env) -> ok | {error, posix()}
|
||||
@@ -858,18 +858,18 @@ probably confuse the process.
|
||||
sigaction(Drv, Pids, Signum, Handler) -> ok | {error, posix()}
|
||||
|
||||
Types Signum = integer() | atom()
|
||||
Handler = dfl | ign | trap
|
||||
Handler = sig_dfl | sig_ign | sig_catch
|
||||
|
||||
sigaction(2) : set process behaviour for signals
|
||||
|
||||
dfl : uses the default behaviour for the signal
|
||||
sig_dfl : uses the default behaviour for the signal
|
||||
|
||||
ign : ignores the signal
|
||||
sig_ign : ignores the signal
|
||||
|
||||
trap : catches the signal and sends the controlling Erlang
|
||||
process an event, {signal, atom()}
|
||||
sig_catch : catches the signal and sends the controlling Erlang
|
||||
process an event, {signal, atom()}
|
||||
|
||||
Multiple trapped signals may be reported as one event.
|
||||
Multiple caught signals may be reported as one event.
|
||||
|
||||
signal_constant(Drv, integer()) -> atom() | unknown
|
||||
signal_constant(Drv, Pids, integer()) -> atom() | unknown
|
||||
|
||||
@@ -90,13 +90,13 @@ alcove_sys_sigaction(alcove_state_t *ap, const char *arg, size_t len,
|
||||
if (alcove_decode_atom(arg, len, &index, handler) < 0)
|
||||
return -1;
|
||||
|
||||
if (!strcmp(handler, "dfl")) {
|
||||
if (!strcmp(handler, "sig_dfl")) {
|
||||
act.sa_handler = SIG_DFL;
|
||||
}
|
||||
else if (!strcmp(handler, "ign")) {
|
||||
else if (!strcmp(handler, "sig_ign")) {
|
||||
act.sa_handler = SIG_IGN;
|
||||
}
|
||||
else if (!strcmp(handler, "trap")) {
|
||||
else if (!strcmp(handler, "sig_catch")) {
|
||||
act.sa_handler = sighandler;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -93,7 +93,7 @@ allow(#state{pid = Drv}) ->
|
||||
|
||||
trap(#state{pid = Drv}) ->
|
||||
{ok, Pid} = alcove:fork(Drv),
|
||||
ok = alcove:sigaction(Drv, [Pid], sigsys, trap),
|
||||
ok = alcove:sigaction(Drv, [Pid], sigsys, sig_catch),
|
||||
|
||||
enforce(Drv, [Pid], ?BPF_STMT(?BPF_RET+?BPF_K, ?SECCOMP_RET_TRAP)),
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ start() ->
|
||||
|
||||
{ok, Drv} = alcove_drv:start([{exec, Exec}, {maxchild, 8}]),
|
||||
|
||||
ok = alcove:sigaction(Drv, sigchld, trap),
|
||||
ok = alcove:sigaction(Drv, sigpipe, ign),
|
||||
ok = alcove:sigaction(Drv, sigchld, sig_catch),
|
||||
ok = alcove:sigaction(Drv, sigpipe, sig_ign),
|
||||
|
||||
case {Use_fork, os:type()} of
|
||||
{false, {unix,linux} = OS} ->
|
||||
@@ -427,11 +427,11 @@ badpid(#state{pid = Drv}) ->
|
||||
signal(#state{pid = Drv}) ->
|
||||
{ok, Child1} = alcove:fork(Drv),
|
||||
|
||||
SA0 = alcove:sigaction(Drv, [Child1], sigterm, ign),
|
||||
SA0 = alcove:sigaction(Drv, [Child1], sigterm, sig_ign),
|
||||
Kill0 = alcove:kill(Drv, Child1, sigterm),
|
||||
Pid0 = alcove:getpid(Drv, [Child1]),
|
||||
|
||||
SA1 = alcove:sigaction(Drv, [Child1], sigterm, dfl),
|
||||
SA1 = alcove:sigaction(Drv, [Child1], sigterm, sig_dfl),
|
||||
Kill1 = alcove:kill(Drv, Child1, sigterm),
|
||||
waitpid(Drv, [], Child1),
|
||||
alcove:kill(Drv, Child1, 0),
|
||||
@@ -656,7 +656,7 @@ execve(#state{pid = Drv}) ->
|
||||
|
||||
stream(#state{pid = Drv}) ->
|
||||
Chain = chain(Drv, 16),
|
||||
ok = alcove:sigaction(Drv, Chain, sigpipe, dfl),
|
||||
ok = alcove:sigaction(Drv, Chain, sigpipe, sig_dfl),
|
||||
DefaultCount = 1 * 1024 * 1024,
|
||||
Count = getenv("ALCOVE_TEST_STREAM_COUNT", integer_to_list(DefaultCount)),
|
||||
% XXX procs in the fork path may exit before all the data has
|
||||
|
||||
Reference in New Issue
Block a user