Skip to content

Commit

Permalink
Merge pull request #1262 from terinjokes/sigwinch
Browse files Browse the repository at this point in the history
libcrun: handle SIGWINCH by resizing terminal_fd
  • Loading branch information
giuseppe committed Aug 8, 2023
2 parents 4ee9bde + 907d032 commit 727fd28
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include <sys/epoll.h>
#include <sys/socket.h>
#include <sys/capability.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <grp.h>
#include <git-version.h>

Expand Down Expand Up @@ -1980,6 +1982,7 @@ wait_for_process (struct wait_for_process_args *args, libcrun_error_t *err)
while (1)
{
struct signalfd_siginfo si;
struct winsize ws;
ssize_t res;
struct epoll_event events[10];
int i, nr_events;
Expand Down Expand Up @@ -2039,6 +2042,19 @@ wait_for_process (struct wait_for_process_args *args, libcrun_error_t *err)
if (last_process)
return container_exit_code;
}
else if (si.ssi_signo == SIGWINCH)
{
if (UNLIKELY (args->terminal_fd < 0))
return 0;

ret = ioctl (0, TIOCGWINSZ, &ws);
if (UNLIKELY (ret < 0))
return crun_error_wrap (err, "copy terminal size from stdin");

ret = ioctl (args->terminal_fd, TIOCSWINSZ, &ws);
if (UNLIKELY (ret < 0))
return crun_error_wrap (err, "copy terminal size to pty");
}
else
{
/* Send any other signal to the child process. */
Expand Down

0 comments on commit 727fd28

Please sign in to comment.