NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: cannot start detached sessions (with -m -d) back to back



RVP wrote:
On Fri, 31 Dec 2021, RVP wrote:

OP: Try this patch:

---START---
diff -u screen-4.8.0{.orig,}/screen.c --- screen-4.8.0.orig/screen.c 2020-02-05 20:09:38.000000000 +0000
+++ screen-4.8.0/screen.c       2021-12-31 01:56:30.470670972 +0000
@@ -1801,6 +1801,10 @@
    struct win *p = windows;
    windows = windows->w_next;
    FreeWindow(p);
+    if (p->w_pid > 0) {
+      debug1("Hangup(%d);\n", p->w_pid);
+      killpg(p->w_pid, SIGHUP);
+    }
  }

  if (ServerSocket != -1) {
---END---


I goofed that (use-after-free). Try this one please:

---START---
diff -urN screen-4.8.0.orig/screen.c screen-4.8.0/screen.c
--- screen-4.8.0.orig/screen.c  2021-12-31 03:27:41.988827000 +0000
+++ screen-4.8.0/screen.c       2021-12-31 03:26:47.995416000 +0000
@@ -1801,8 +1801,13 @@
    debug1("Finit(%d);\n", i);
    while (windows) {
      struct win *p = windows;
+    pid_t pid = p->w_pid;
      windows = windows->w_next;
      FreeWindow(p);
+    if (pid > 0) {
+      debug1("Hangup(%d);\n", pid);
+      killpg(pid, SIGHUP);
+    }
    }

    if (ServerSocket != -1) {
---END---

oh wow, great work! I will try this as soon as possible, which might not be until tomorrow.




Home | Main Index | Thread Index | Old Index