diff --git a/0019-do-not-close-ptx-fd-incase-of-sighup-signal-was-rece.patch b/0019-do-not-close-ptx-fd-incase-of-sighup-signal-was-rece.patch new file mode 100644 index 0000000000000000000000000000000000000000..a74a4b1eca997d8a89cb738ffb0748ad71f5ed89 --- /dev/null +++ b/0019-do-not-close-ptx-fd-incase-of-sighup-signal-was-rece.patch @@ -0,0 +1,42 @@ +From b449bcbe0d7684e06a38ffea35c92ec7f2979236 Mon Sep 17 00:00:00 2001 +From: jikai +Date: Fri, 6 Dec 2024 02:32:09 +0000 +Subject: [PATCH] do not close ptx fd incase of sighup signal was received + +Signed-off-by: jikai +--- + src/lxc/terminal.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c +index acf6785..7ce53cd 100644 +--- a/src/lxc/terminal.c ++++ b/src/lxc/terminal.c +@@ -855,8 +855,24 @@ static int lxc_terminal_ptx_io(struct lxc_terminal *terminal) + int r, w, w_log, w_rbuf; + + w = r = lxc_read_nointr(terminal->ptx, buf, sizeof(buf)); ++#ifdef HAVE_ISULAD ++ if (r <= 0) { ++ terminal->ptx = -EBADF; ++ /* write remained buffer to terminal log */ ++ if (terminal->log_fd >= 0) { ++ w_log = isulad_lxc_terminal_write_log_file(terminal, "stdout", NULL, 0); ++ if (w_log < 0) ++ TRACE("Failed to write %d bytes to terminal log", r); ++ } ++ /* notes: do not close the ptx fd due to if we close the fd, the process may ++ * recive SIGHUP and the exit code will be 129 (128 + 1) ++ */ ++ return -1; ++ } ++#else + if (r <= 0) + return -1; ++#endif + + w_rbuf = w_log = 0; + /* write to peer first */ +-- +2.34.1 + diff --git a/lxc.spec b/lxc.spec index 5f763e5e38206735ec380ce76dc2fd2aefb712f7..6ac2021088fa82f58c2fad49b1782e23c39edb18 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 17 +%global _release 18 %bcond isulad 1 Name: lxc @@ -27,6 +27,7 @@ Patch0015: 0015-append-mntopt-to-mntdata-if-not-found-in-mount_opt.patch Patch0016: 0016-unfreeze-freezing-container-and-bugfix-for-files.lim.patch Patch0017: 0017-fix-error-of-cc.compiles-on-aarch.patch Patch0018: 0018-add-fPIC-compile-option.patch +Patch0019: 0019-do-not-close-ptx-fd-incase-of-sighup-signal-was-rece.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) @@ -216,6 +217,12 @@ meson test -C build %endif %changelog +* Fri Dec 06 2024 jikai - 5.0.2-18 +- Type: bugfix +- ID:NA +- SUG:NA +- DESC: do not close ptx fd in case of sighup signal received + * Mon Nov 25 2024 jikai - 5.0.2-17 - Type: bugfix - ID:NA