You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got lost in the source code. I'm experiment with namespaces, and when I exec systemd inside my wrapper program, the output is not printed to stdout.
I tried using openpty, this is what I was doing so far:
intpty;
inttty;
charpty_node[256];
if (openpty(&pty, &tty, pty_node, NULL, NULL))
exit_with_error("openpty");
bind_console(pty_node);
pid_tpid=fork();
charbuffer[1024];
ssize_tread_count;
intstatus;
switch (pid) {
case-1:
exit_with_error("fork");
case0:
if(setsid() <0)
exit_with_error("setsid");
if (ioctl(tty, TIOCSCTTY, 1))
exit_with_error("ioctl");
// exec systemd hereif (execvp(argv[1], argv+1))
exit_with_error("execvp");
default:
while ((read_count=read(pty, buffer, 1024)) >0) {
char*ptr=buffer;
size_tptr_len= (size_t) read_count;
while (ptr_len>0) {
ssize_twrite_count=write(STDOUT_FILENO, ptr, ptr_len);
if (write_count<0)
exit_with_error("write to stdout");
ptr+=write_count;
ptr_len-=write_count;
}
}
if (read_count<0)
exit_with_error("read from pty");
rc=waitpid(pid, &status, 0);
printf("%d status: %d\n", pid, status);
}
bind_console links /dev/console with pty_node returned from openpty. Using this approach I can see the output only if I set ForwardToConsole=yes and TTYPath=/dev/console in /etc/systemd/journald.conf, and I failed to see the login prompt.
I'm wondering how does podman handle this? podman could capture the output of systemd and show login prompt using --tty without configuring the journald.conf, what's the trick behind the scene? What am I missing here? Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I got lost in the source code. I'm experiment with namespaces, and when I exec systemd inside my wrapper program, the output is not printed to stdout.
I tried using
openpty
, this is what I was doing so far:bind_console
links/dev/console
withpty_node
returned from openpty. Using this approach I can see the output only if I setForwardToConsole=yes
andTTYPath=/dev/console
in/etc/systemd/journald.conf
, and I failed to see the login prompt.I'm wondering how does podman handle this? podman could capture the output of systemd and show login prompt using
--tty
without configuring the journald.conf, what's the trick behind the scene? What am I missing here? Thanks!Beta Was this translation helpful? Give feedback.
All reactions