1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 #include "process-util.h"
9 #include "spawn-ask-password-agent.h"
12 static pid_t agent_pid
= 0;
14 int ask_password_agent_open(void) {
20 /* We check STDIN here, not STDOUT, since this is about input,
22 if (!isatty(STDIN_FILENO
))
25 if (!is_main_thread())
28 r
= fork_agent("(sd-askpwagent)",
31 SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH
,
32 SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH
, "--watch", NULL
);
34 return log_error_errno(r
, "Failed to fork TTY ask password agent: %m");
39 void ask_password_agent_close(void) {
44 /* Inform agent that we are done */
45 (void) kill_and_sigcont(agent_pid
, SIGTERM
);
46 (void) wait_for_terminate(agent_pid
, NULL
);