libutil: remove unused DoSignalSave
all uses are DoSignalSave::Save now, and introducing new DontSave uses should be avoided as much as possible. process management is already a mess, simplifying it somewhat will make our life easier in the future. Change-Id: I77eecabe45bee9de18fba0dfc948403d3ce46dfe
This commit is contained in:
@@ -122,16 +122,10 @@ void saveSignalMask() {
|
||||
savedSignalMaskIsSet = true;
|
||||
}
|
||||
|
||||
void startSignalHandlerThread(DoSignalSave doSave)
|
||||
void startSignalHandlerThread()
|
||||
{
|
||||
updateWindowSize();
|
||||
|
||||
switch (doSave) {
|
||||
case DoSignalSave::Save:
|
||||
saveSignalMask();
|
||||
break;
|
||||
case DoSignalSave::DontSaveBecauseAdvancedProcess: break;
|
||||
}
|
||||
saveSignalMask();
|
||||
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
|
||||
+7
-33
@@ -1,24 +1,16 @@
|
||||
#pragma once
|
||||
/** @file Signal handling in Lix
|
||||
*
|
||||
* Processes are expected to be either:
|
||||
* - Advanced processes which call into Lix's logic, like the daemon processes.
|
||||
* - Basic processes that are just going to execve.
|
||||
*
|
||||
* Processes should be set up accordingly following a fork:
|
||||
* In the first case, such processes should have a signal handler thread that
|
||||
* catches SIGINT and dispatches it to the rest of the system so they should
|
||||
* call startSignalHandlerThread(). In the second case, processes should call
|
||||
* restoreProcessContext(), possibly with `false` (depends on whether mounts
|
||||
* should be restored), which will unmask SIGINT and other signals that were
|
||||
* previously masked in an advanced process such as the one that started
|
||||
* them, so the process can be interrupted.
|
||||
* Processes are expected to be simple, mostly just calling execve.
|
||||
* All processes should call restoreProcessContext(), possibly with
|
||||
* `false` (depends on whether mounts should be restored), which will unmask
|
||||
* SIGINT and other signals that were previously masked in an advanced process
|
||||
* such as the one that started them, so the process can be interrupted.
|
||||
*
|
||||
* It is generally a mistake to fork a process without at least calling
|
||||
* restoreSignals() or restoreProcessContext().
|
||||
*/
|
||||
|
||||
|
||||
#include "lix/libutil/error.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
|
||||
@@ -66,32 +58,14 @@ MakeError(Interrupted, BaseError);
|
||||
|
||||
void restoreSignals();
|
||||
|
||||
|
||||
/**
|
||||
* Whether to save the signal mask when starting the signal handler thread.
|
||||
*
|
||||
* The signal mask shouldn't be saved if the current signal mask is the one for
|
||||
* processes with a signal handler thread.
|
||||
*/
|
||||
enum class DoSignalSave
|
||||
{
|
||||
Save,
|
||||
DontSaveBecauseAdvancedProcess,
|
||||
};
|
||||
|
||||
/**
|
||||
* Start a thread that handles various signals. Also block those signals
|
||||
* on the current thread (and thus any threads created by it).
|
||||
*
|
||||
* Optionally saves the signal mask before changing the mask to block those
|
||||
* Also saves the signal mask before changing the mask to block those
|
||||
* signals. See saveSignalMask().
|
||||
*
|
||||
* This should also be executed after certain forks from Lix processes that
|
||||
* expect to be "advanced" (see file doc comment), since the signal thread will
|
||||
* die on fork. Of course this whole situation is kind of unsound since we
|
||||
* definitely violate async-signal-safety requirements, but, well.
|
||||
*/
|
||||
void startSignalHandlerThread(DoSignalSave doSave = DoSignalSave::Save);
|
||||
void startSignalHandlerThread();
|
||||
|
||||
/**
|
||||
* Saves the signal mask, which is the signal mask that nix will restore
|
||||
|
||||
Reference in New Issue
Block a user