1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright 2011 Lennart Poettering
11 #include "process-util.h"
12 #include "spawn-ask-password-agent.h"
15 static pid_t agent_pid
= 0;
17 int ask_password_agent_open(void) {
23 /* We check STDIN here, not STDOUT, since this is about input,
25 if (!isatty(STDIN_FILENO
))
28 if (!is_main_thread())
31 r
= fork_agent("(sd-askpwagent)",
34 SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH
,
35 SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH
, "--watch", NULL
);
37 return log_error_errno(r
, "Failed to fork TTY ask password agent: %m");
42 void ask_password_agent_close(void) {
47 /* Inform agent that we are done */
48 (void) kill_and_sigcont(agent_pid
, SIGTERM
);
49 (void) wait_for_terminate(agent_pid
, NULL
);