tools.test io.launcher arrays io namespaces continuations math
io.encodings.binary io.encodings.ascii accessors kernel
sequences io.encodings.utf8 destructors io.streams.duplex locals
-concurrency.promises threads unix.process calendar unix ;
+concurrency.promises threads unix.process calendar unix
+unix.process debugger.unix io.timeouts io.launcher.unix ;
[ ] [
[ "launcher-test-1" temp-file delete-file ] ignore-errors
s 3 seconds ?promise-timeout 0 =
]
] unit-test
+
+! Make sure that subprocesses don't inherit our signal mask
+
+! First, ensure that the Factor VM ignores SIGPIPE
+: send-sigpipe ( pid -- )
+ "SIGPIPE" signal-names index 1 +
+ kill io-error ;
+
+[ ] [ current-process-handle send-sigpipe ] unit-test
+
+! Spawn a process
+[ T{ signal f 13 } ] [
+ "sleep 1000" run-detached
+ [ handle>> send-sigpipe ]
+ [ 2 seconds swap set-timeout ]
+ [ wait-for-process ]
+ tri
+] unit-test
vm->dispatch_signal(uap,factor::misc_signal_handler_impl);
}
+void ignore_signal_handler(int signal, siginfo_t *siginfo, void *uap)
+{
+}
+
void fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap)
{
factor_vm *vm = current_vm();
sigaction_safe(SIGQUIT,&misc_sigaction,NULL);
sigaction_safe(SIGILL,&misc_sigaction,NULL);
+ /* We don't use SA_IGN here because then the ignore action is inherited
+ by subprocesses, which we don't want. There is a unit test in
+ io.launcher.unix for this. */
memset(&ignore_sigaction,0,sizeof(struct sigaction));
sigemptyset(&ignore_sigaction.sa_mask);
- ignore_sigaction.sa_handler = SIG_IGN;
+ ignore_sigaction.sa_sigaction = ignore_signal_handler;
+ ignore_sigaction.sa_flags = SA_SIGINFO | SA_ONSTACK;
sigaction_safe(SIGPIPE,&ignore_sigaction,NULL);
}
THREADHANDLE start_thread(void *(*start_routine)(void *),void *args);
inline static THREADHANDLE thread_id() { return pthread_self(); }
-void signal_handler(int signal, siginfo_t* siginfo, void* uap);
-void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap);
-
u64 nano_count();
void sleep_nanos(u64 nsec);
void open_console();