mirror of
https://github.com/NixOS/nix
synced 2025-06-28 17:51:15 +02:00
Refactor option handling
This commit is contained in:
parent
5bed74d1b0
commit
47e185847e
10 changed files with 503 additions and 531 deletions
|
@ -645,8 +645,10 @@ bool matchUser(const string & user, const string & group, const Strings & users)
|
|||
#define SD_LISTEN_FDS_START 3
|
||||
|
||||
|
||||
static void daemonLoop()
|
||||
static void daemonLoop(char * * argv)
|
||||
{
|
||||
chdir("/");
|
||||
|
||||
/* Get rid of children automatically; don't let them become
|
||||
zombies. */
|
||||
setSigChldAction(true);
|
||||
|
@ -766,9 +768,9 @@ static void daemonLoop()
|
|||
setSigChldAction(false);
|
||||
|
||||
/* For debugging, stuff the pid into argv[1]. */
|
||||
if (clientPid != -1 && argvSaved[1]) {
|
||||
if (clientPid != -1 && argv[1]) {
|
||||
string processName = int2String(clientPid);
|
||||
strncpy(argvSaved[1], processName.c_str(), strlen(argvSaved[1]));
|
||||
strncpy(argv[1], processName.c_str(), strlen(argv[1]));
|
||||
}
|
||||
|
||||
/* Handle the connection. */
|
||||
|
@ -792,18 +794,27 @@ void run(Strings args)
|
|||
{
|
||||
for (Strings::iterator i = args.begin(); i != args.end(); ) {
|
||||
string arg = *i++;
|
||||
if (arg == "--daemon") /* ignored for backwards compatibility */;
|
||||
}
|
||||
|
||||
chdir("/");
|
||||
daemonLoop();
|
||||
}
|
||||
|
||||
|
||||
void printHelp()
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
showManPage("nix-daemon");
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
|
||||
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--daemon")
|
||||
; /* ignored for backwards compatibility */
|
||||
else if (*arg == "--help")
|
||||
showManPage("nix-daemon");
|
||||
else if (*arg == "--version")
|
||||
printVersion("nix-daemon");
|
||||
else return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
daemonLoop(argv);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
string programId = "nix-daemon";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue