Skip to content

tmux -D keeps zombies around with --enable-utempter #4559

Closed

Description

@archer-321

Issue description

If tmux is built with --enable-utempter, the following commands somewhat reliably lead to the shell process becoming a zombie that's not reaped until the main tmux -D process terminates.

Steps to reproduce (see note below)

  1. Compile tmux with ./configure --enable-utempter && make.
  2. Run ./tmux -Ltest kill-server && ./tmux -Ltest -f/dev/null -D.
  3. In another terminal, run ./tmux -Ltest -f/dev/null to start a new session with the default shell. This has been tested both with bash and fish.
  4. Wait a few seconds and exit the shell.
  5. The shell started by the client process will be a zombie process of the tmux -D command.

Note: Interestingly enough, I am not able to reproduce this problem when enabling verbose logging (-vv). This issue might be because of a race condition. If that's indeed the case, I imagine different hardware/operating system configurations might get different results when trying to reproduce this issue.

Related issues

This bug might be related to #311. However, this problem only occurs when using -D. Moreover, #311 seems to be fixed, so I opened a new issue instead.

Required information

Please provide the following information:

  • tmux version (tmux -V): tmux next-3.6 (latest master/865117a0)
  • Platform (uname -sp): Linux unknown (Debian 12 running in a container; docker.io/debian:stable)
  • $TERM
    • inside: xterm
    • and outside of tmux (echo $TERM): tmux-256color
  • Logs from tmux (tmux kill-server; tmux -vv new): As described above, I can't reproduce the issue when running the same commands with -vv.

Thank you for creating tmux! It's an essential part of my terminal workflows.

Activity

  1. nicm commented on Jul 19, 2025

    @nicm
    Member

    Does it make any difference if you do this as well?

    --- a/server-fn.c
    +++ b/server-fn.c
    @@ -318,6 +318,7 @@ server_destroy_pane(struct window_pane *wp, int notify)
            if (wp->fd != -1) {
     #ifdef HAVE_UTEMPTER
                    utempter_remove_record(wp->fd);
    +               kill(getpid(), SIGCHLD);
     #endif
                    bufferevent_free(wp->event);
                    wp->event = NULL;
    diff --git a/window.c b/window.c
    index 6f8606e5..6f2c19fe 100644
    --- a/window.c
    +++ b/window.c
    @@ -982,6 +982,7 @@ window_pane_destroy(struct window_pane *wp)
            if (wp->fd != -1) {
     #ifdef HAVE_UTEMPTER
                    utempter_remove_record(wp->fd);
    +               kill(getpid(), SIGCHLD);
     #endif
                    bufferevent_free(wp->event);
                    close(wp->fd);
    
  2. archer-321 commented on Jul 20, 2025

    @archer-321
    Author

    Thanks for the reply!
    Adding the lines to both files indeed fixes the issue.

    I also tried creating multiple panes and closing them individually; as long as the server was using the patch, no zombie processes were left behind.

  3. nicm commented on Jul 20, 2025

    @nicm
    Member

    Good stuff, applied now. Thanks!

  4. github-actions commented on Aug 20, 2025

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed.

  5. locked as resolved and limited conversation to collaborators on Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions