mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
connect stdin to /dev/null
laminard is a daemon process and does not read from stdin. Usually we can rely on the process mananger to do this for us, but if not (e.g. laminard is run interactively), we need this so that child processes (job runs) will not be able to block on stdin. resolves #125
This commit is contained in:
parent
081becf23a
commit
d5cfa3b94e
15
src/main.cpp
15
src/main.cpp
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2016 Oliver Giles
|
||||
/// Copyright 2015-2020 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@ -20,9 +20,12 @@
|
||||
#include "leader.h"
|
||||
#include "server.h"
|
||||
#include "log.h"
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <kj/async-unix.h>
|
||||
#include <kj/filesystem.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static Laminar* laminar;
|
||||
static Server* server;
|
||||
@ -51,6 +54,14 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
// The parent process hopefully connected stdin to /dev/null, but
|
||||
// do it again here just in case. This is important because stdin
|
||||
// is inherited to job runs via the leader process, and some
|
||||
// processes misbehave if they can successfully block on reading
|
||||
// from stdin.
|
||||
close(STDIN_FILENO);
|
||||
LASSERT(open("/dev/null", O_RDONLY) == STDIN_FILENO);
|
||||
|
||||
auto ioContext = kj::setupAsyncIo();
|
||||
|
||||
Settings settings;
|
||||
|
Loading…
Reference in New Issue
Block a user