Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
steam
systemd
Commits
7fc01d33
Commit
7fc01d33
authored
Feb 13, 2011
by
Lennart Poettering
Browse files
systemctl: minor optimizations
parent
060ed82e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/systemctl.c
View file @
7fc01d33
...
...
@@ -161,6 +161,7 @@ static void spawn_ask_password_agent(void) {
};
int
fd
;
bool
stdout_is_tty
,
stderr_is_tty
;
/* Make sure the agent goes away when the parent dies */
if
(
prctl
(
PR_SET_PDEATHSIG
,
SIGTERM
)
<
0
)
...
...
@@ -174,7 +175,10 @@ static void spawn_ask_password_agent(void) {
/* Don't leak fds to the agent */
close_all_fds
(
NULL
,
0
);
if
(
!
isatty
(
STDOUT_FILENO
)
||
!
isatty
(
STDERR_FILENO
))
{
stdout_is_tty
=
isatty
(
STDOUT_FILENO
);
stderr_is_tty
=
isatty
(
STDERR_FILENO
);
if
(
!
stdout_is_tty
||
!
stderr_is_tty
)
{
/* Detach from stdout/stderr. and reopen
* /dev/tty for them. This is important to
* ensure that when systemctl is started via
...
...
@@ -187,15 +191,11 @@ static void spawn_ask_password_agent(void) {
_exit
(
EXIT_FAILURE
);
}
if
(
!
isatty
(
STDOUT_FILENO
))
{
close
(
STDOUT_FILENO
);
if
(
!
stdout_is_tty
)
dup2
(
fd
,
STDOUT_FILENO
);
}
if
(
!
isatty
(
STDERR_FILENO
))
{
close
(
STDERR_FILENO
);
if
(
!
stderr_is_tty
)
dup2
(
fd
,
STDERR_FILENO
);
}
if
(
fd
>
2
)
close
(
fd
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment