init: Introduce RequiresConsole()

Prepare for adding more code in the parent process that depends on
whether or not a console is required.

Bug: 213617178
Change-Id: I066ede32fcd4ce09d06be23158f3c1970064a697
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
Bart Van Assche 2022-11-14 16:54:03 -08:00
parent c8f34254b8
commit 987391656f
2 changed files with 6 additions and 1 deletions

View File

@ -240,7 +240,7 @@ Result<void> SetProcessAttributes(const ProcessAttributes& attr) {
}
}
if (!attr.console.empty()) {
if (RequiresConsole(attr)) {
setsid();
OpenConsole(attr.console);
} else {

View File

@ -95,6 +95,11 @@ struct ProcessAttributes {
int priority;
bool stdio_to_kmsg;
};
inline bool RequiresConsole(const ProcessAttributes& attr) {
return !attr.console.empty();
}
Result<void> SetProcessAttributes(const ProcessAttributes& attr);
Result<void> WritePidToFiles(std::vector<std::string>* files);