Re: tmux: create window failed (too many open files)
Applied, thanks. On Wed, Sep 26, 2012 at 05:19:56PM +0200, S?bastien Marie wrote: The patch seems to resolv the problem. Only seems, because I only known to reproduce it for the 'tty' descriptor, but I hope the 'null' descriptor will be in the same case :-) But I will use this version for test it. Thanks a lot. -- Sebastien Marie On Wed, Sep 26, 2012 at 03:42:23PM +0100, Nicholas Marriott wrote: Try this please: Index: server-client.c === RCS file: /cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.79 diff -u -p -r1.79 server-client.c --- server-client.c 3 Sep 2012 09:32:38 - 1.79 +++ server-client.c 26 Sep 2012 14:42:04 - @@ -912,8 +912,10 @@ server_client_msg_identify( return; } - if (!isatty(fd)) - return; + if (!isatty(fd)) { + close(fd); + return; + } data-term[(sizeof data-term) - 1] = '\0'; tty_init(c-tty, c, fd, data-term); if (data-flags IDENTIFY_UTF8) On Wed, Sep 26, 2012 at 01:40:53PM +0200, S?bastien Marie wrote: Hi, After some tests (on a new tmux server, started with tmux -L test ...), I could (partially) reproduce the problem. Partially, because: in fstat output there are 2 kinds of bugged entries: tty and null tty: 181 descriptors null: 320 descriptors And I arrived to keep descriptors opened against /dev/tty , but not against /dev/null (for the moment, but I monitor what in my use what generate this...). This occurs with urlview (textproc/urlview), with a custom url_handler. Basically urlview take a text in stdin (generally an email), and display a menu (ncurses) of URLs found in the text. The user choose an URL, and urlview start a command (in my case, a custom script). First, my configuration: $ cat ~/.urlview # command to invoke for selected URL COMMAND /home/semarie/.local/bin/urlview_handler.sh Next, the command started by urlview: $ cat /home/semarie/.local/bin/urlview_handler.sh #!/bin/sh # if TMUX enable, update environment if [ -n ${TMUX} ] ; then eval `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$/=\\1\/'` unset `tmux show-environment | grep'^-' | sed 's/^-//'` export `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$//'` fi # check DISPLAY if [ -n ${DISPLAY} ] ; then exec chrome $@ fi # if not DISPLAY exec lynx $@ And when I launch the command: $ echo 'http://www.openbsd.org/' | urlview 3 new descriptors against tty are opened and not closed after the command. There are directly correlate with the 3 tmux show-environment in the script. I don't remind exactly the purpose of updating the environnement in the script... should be to keep kerberos ticket or display environnement in text-mode ... but ? Additionnaly, running the url_hander alone (without urlview) don't trigger the problem. I will disabling the part of updating environment in my script (and if I always need it, I will recall when something won't work !) I will post when I have more info. Please let me known if more informations are needed. Thanks. -- Sebastien Marie
Re: tmux: create window failed (too many open files)
Are you running a tmux command from any shell script or cron or anything? There are only two places tmux itself opens /dev/null and they are both after fork so this must be /dev/null passed with imsg from a client. Also please should me output of tmux info. On Wed, Sep 26, 2012 at 09:29:50AM +0200, S?bastien Marie wrote: Hi, I'm running -current (not latest, only GENERIC.MP#20), see dmesg below. I run in a error in tmux (a long session: 10 days for now), when a want to create a new window (C-b C-c), I have this error: Create window failed: exec ksh: Too many open files Note, my default shell in tmux.conf is exec ksh (see ~/.tmux.conf below) My limit for open files are standard: semarie@bert:~$ ulimit -n 512 Currently, I have only 4 windows in this sessions, but: semarie@bert:~$ fstat -u semarie | grep tmux semarie tmux3941 wd /home 4053504 drwx-- r 2560 semarie tmux39410 / 17084 crw--w rwttyp5 semarie tmux39411 / 17084 crw--w rwttyp5 semarie tmux39412 / 17084 crw--w rwttyp5 semarie tmux39413 kqueue 0xd8c0f3d4 0 state: W semarie tmux39414 /home 4053890 -rw-r--r-- r 1859 semarie tmux39415* unix stream 0xd31c7680 - 0xd4105380 semarie tmux1509 wd /home 4053504 drwx-- r 2560 semarie tmux15090 / 17621 crw-rw-rw- rw null semarie tmux15091 / 17621 crw-rw-rw- rw null semarie tmux15092 / 17621 crw-rw-rw- rw null semarie tmux15093 kqueue 0xd8c0f310 0 state: W semarie tmux15094 /home 4053942 -rw-r--r-- r 1805 semarie tmux15095* unix stream 0xd4105380 - 0xd31c7680 semarie tmux15096* unix stream 0xd3228740 semarie tmux15097 / 17084 crw--w rwttyp5 semarie tmux15099 / 17621 crw-rw-rw- r null semarie tmux1509 10 / 17079 crw-rw-rw- rwptyp2 semarie tmux1509 11 / 17621 crw-rw-rw- r null semarie tmux1509 12 / 17621 crw-rw-rw- r null semarie tmux1509 13 / 17621 crw-rw-rw- r null semarie tmux1509 14 / 17621 crw-rw-rw- r null semarie tmux1509 15 / 17621 crw-rw-rw- r null semarie tmux1509 16 / 17621 crw-rw-rw- r null [...] semarie tmux1509 503 / 17621 crw-rw-rw- r null semarie tmux1509 504 / 17621 crw-rw-rw- r null semarie tmux1509 505 / 17621 crw-rw-rw- r null semarie tmux1509 506 / 17621 crw-rw-rw- r null semarie tmux1509 507 / 17621 crw-rw-rw- r null semarie tmux1509 508 / 17621 crw-rw-rw- r null semarie tmux1509 509 / 17618 crw-rw-rw- r tty semarie tmux1509 510 / 17618 crw-rw-rw- r tty There are 510 descriptors opened... Any hints ? Does tmux could not closed not-need descriptors for old created windows ? It will try too keep this session running for debug if need... I could also upgrade to latest snapshot if needed. But I don't show any commit to tmux that seems related to that. But I could be wrong: please let me know. Thanks. -- Sebastien Marie My ~/.tmux.conf set -g default-command exec ksh set -g status-right #(sysctl -n vm.loadavg) # Statusbar properties. set -g display-time 3000 set -g status-bg black set -g status-fg cyan set-window-option -g window-status-current-attr bright,reverse set-window-option -g window-status-current-bg cyan set-window-option -g window-status-current-fg black # divers set -g default-path set -g bell-action any set -g set-titles on set -g base-index 1 set -g history-limit 5000 set -g update-environment DISPLAY WINDOWID SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION DBUS_SESSION_BUS_ADDRESS XDG_SESSION_COOKIE KRB5CCNAME My dmesg: OpenBSD 5.2-current (GENERIC.MP) #20: Tue Sep 11 11:54:03 MDT 2012 dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP cpu0: Genuine Intel(R) CPU T2400 @ 1.83GHz (GenuineIntel 686-class) 1.83 GHz cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,MWAIT,VMX,EST,TM2,xTPR,PDCM real mem = 2137399296 (2038MB) avail mem = 2091552768 (1994MB) mainbus0 at root bios0 at mainbus0: AT/286+ BIOS, date 03/09/06, BIOS32 rev. 0 @ 0xffa10, SMBIOS rev. 2.4 @ 0xf7b70 (44 entries) bios0: vendor Dell Inc. version A03 date 03/09/2006 bios0: Dell Inc. MM061 acpi0 at bios0: rev 0 acpi0: sleep states S0 S3 S4 S5 acpi0: tables DSDT FACP APIC MCFG BOOT SSDT
Re: tmux: create window failed (too many open files)
On Wed, Sep 26, 2012 at 09:20:25AM +0100, Nicholas Marriott wrote: Are you running a tmux command from any shell script or cron or anything? I used X11 (cwm). I open a terminal (rxvt), maximize size, and run: $ tmux attach -d -t semarie (normally, via an alias) There are only two places tmux itself opens /dev/null and they are both after fork so this must be /dev/null passed with imsg from a client. Also please should me output of tmux info. (in a ksh in the session) semarie@bert:~$ tmux info semarie@bert:~$ echo $? 1 semarie@bert:~$ so via the tmux command-line (C-b : + info) pid 1509, started Sat Sep 15 10:17:49 2012 [137/137] socket path /tmp/tmux-1000/default, debug level 0 system is OpenBSD 5.2 GENERIC.MP#20 i386 configuration file is /home/semarie/.tmux.conf protocol version is 7 Clients: 0: /dev/ttyp3 (5, 7): semarie [80x24 rxvt-256color bs=177 xterm=95] [flags=0x1/0x3b, references=0] Sessions: [5/10] 0: semarie: 4 windows (created Sat Sep 15 10:17:49 2012) [127x42] [flags=0x0] 1: ksh [127x42] [flags=0x8, references=1, last layout=-1] 0: /dev/ttyp5 24460 131 1/42, 80 bytes; UTF-8 0/42, 0 bytes 2: ksh [127x42] [flags=0x8, references=1, last layout=-1] 0: /dev/ttyp6 19418 421 3/42, 285 bytes; UTF-8 0/42, 0 bytes 3: ksh [127x42] [flags=0x8, references=1, last layout=-1] 0: /dev/ttyp2 2926 10 4/21, 405 bytes; UTF-8 0/21, 0 bytes 4: ksh [127x42] [flags=0x8, references=1, last layout=-1] 0: /dev/ttyp1 29566 185 153/156, 45190 bytes; UTF-8 2/156, 880 bytes Terminals: [117/137] rxvt-256color [references=1, flags=0x1]: 1: acsc: (string) ``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~ 0: AX: (flag) true 2: bel: (string) \007 3: blink: (string) \033[5m 4: bold: (string) \033[1m 5: Cc: [missing] 6: civis: (string) \033[?25l 7: clear: (string) \033[H\033[2J 8: cnorm: (string) \033[?25h 9: colors: (number) 256 10: Cr: [missing] 11: Cs: [missing] 12: csr: (string) \033[%i%p1%d;%p2%dr 13: Csr: [missing] 14: cub: (string) \033[%p1%dD 15: cub1: (string) \010 16: cud: (string) \033[%p1%dB 17: cud1: (string) \012 18: cuf: (string) \033[%p1%dC 19: cuf1: (string) \033[C 20: cup: (string) \033[%i%p1%d;%p2%dH 21: cuu: (string) \033[%p1%dA 22: cuu1: (string) \033[A 23: dch: [missing] 24: dch1: [missing] 25: dim: [missing] 26: dl: (string) \033[%p1%dM 27: dl1: (string) \033[M 28: E3: [missing] 29: el: (string) \033[K 30: el1: (string) \033[1K 31: enacs: (string) \033(B\033)0 32: fsl: (string) \007 33: home: (string) \033[H 34: hpa: (string) \033[%i%p1%dG 35: ich: (string) \033[%p1%d@ 36: ich1: (string) \033[@ 37: il: (string) \033[%p1%dL 38: il1: (string) \033[L 39: invis: [missing] 40: is1: (string) \033[?47l\033=\033[?1l [75/137] 41: is2: (string) \033[r\033[m\033[2J\033[H\033[?7h\033[?1;3;4;6l\033[4l 42: is3: [missing] 43: kcbt: (string) \033[Z 44: kcub1: (string) \033[D 45: kcud1: (string) \033[B 46: kcuf1: (string) \033[C 47: kcuu1: (string) \033[A 48: kDC: (string) \033[3$ 49: kDC3: [missing] 50: kDC4: [missing] 51: kDC5: (string) \033[3^ 52: kDC6: (string) \033[3@ 53: kDC7: [missing] 54: kdch1: (string) \033[3~ 55: kDN: (string) \033[b 56: kDN3: [missing] 57: kDN4: [missing] 58: kDN5: (string) \033Ob 59: kDN6: [missing] 60: kDN7: [missing] 61: kend: (string) \033[8~ 62: kEND: (string) \033[8$ 63: kEND3: [missing] 64: kEND4: [missing] 65: kEND5: (string) \033[8^ 66: kEND6: (string) \033[8@ 67: kEND7: [missing] 68: kf1: (string) \033[11~ 69: kf10: (string) \033[21~ 70: kf11: (string) \033[23~ 71: kf12: (string) \033[24~ 72: kf13: (string) \033[25~ 73: kf14: (string) \033[26~ 74: kf15: (string) \033[28~ 75: kf16: (string) \033[29~ 76: kf17: (string) \033[31~ 77: kf18: (string) \033[32~ 78: kf19: (string) \033[33~ 79: kf2: (string) \033[12~ 80: kf20: (string) \033[34~ 81: kf3: (string) \033[13~ 82: kf4: (string) \033[14~ 83: kf5: (string) \033[15~ 84: kf6: (string) \033[17~ 85: kf7: (string) \033[18~ 86: kf8: (string) \033[19~ 87: kf9: (string) \033[20~ 88: kHOM: (string) \033[7$ 89: kHOM3: [missing] 90: kHOM4: [missing] 91: kHOM5: (string) \033[7^ 92: kHOM6: (string) \033[7@ 93: kHOM7: [missing] 94: khome: (string) \033[7~ 95: kIC: (string) \033[2$ 96: kIC3: [missing] 97: kIC4: [missing] 98: kIC5: (string) \033[2^ 99: kIC6: (string) \033[2@ 100: kIC7: [missing] 101: kich1: (string) \033[2~ 102: kLFT: (string) \033[d 103: kLFT3: [missing] 104: kLFT4: [missing] 105: kLFT5: (string) \033Od 106: kLFT6: [missing] 107: kLFT7: [missing] 108: kmous: (string) \033[M 109: knp: (string) \033[6~ 110: kNXT: (string) \033[6$ 111: kNXT3: [missing] 112: kNXT4: [missing] 113: kNXT5: (string) \033[6^ 114: kNXT6: (string) \033[6@ 115: kNXT7: [missing] 116: kpp: (string) \033[5~ 117: kPRV: (string)
Re: tmux: create window failed (too many open files)
Hi, After some tests (on a new tmux server, started with tmux -L test ...), I could (partially) reproduce the problem. Partially, because: in fstat output there are 2 kinds of bugged entries: tty and null tty: 181 descriptors null: 320 descriptors And I arrived to keep descriptors opened against /dev/tty , but not against /dev/null (for the moment, but I monitor what in my use what generate this...). This occurs with urlview (textproc/urlview), with a custom url_handler. Basically urlview take a text in stdin (generally an email), and display a menu (ncurses) of URLs found in the text. The user choose an URL, and urlview start a command (in my case, a custom script). First, my configuration: $ cat ~/.urlview # command to invoke for selected URL COMMAND /home/semarie/.local/bin/urlview_handler.sh Next, the command started by urlview: $ cat /home/semarie/.local/bin/urlview_handler.sh #!/bin/sh # if TMUX enable, update environment if [ -n ${TMUX} ] ; then eval `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$/=\\1\/'` unset `tmux show-environment | grep'^-' | sed 's/^-//'` export `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$//'` fi # check DISPLAY if [ -n ${DISPLAY} ] ; then exec chrome $@ fi # if not DISPLAY exec lynx $@ And when I launch the command: $ echo 'http://www.openbsd.org/' | urlview 3 new descriptors against tty are opened and not closed after the command. There are directly correlate with the 3 tmux show-environment in the script. I don't remind exactly the purpose of updating the environnement in the script... should be to keep kerberos ticket or display environnement in text-mode ... but ? Additionnaly, running the url_hander alone (without urlview) don't trigger the problem. I will disabling the part of updating environment in my script (and if I always need it, I will recall when something won't work !) I will post when I have more info. Please let me known if more informations are needed. Thanks. -- Sebastien Marie
Re: tmux: create window failed (too many open files)
Try this please: Index: server-client.c === RCS file: /cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.79 diff -u -p -r1.79 server-client.c --- server-client.c 3 Sep 2012 09:32:38 - 1.79 +++ server-client.c 26 Sep 2012 14:42:04 - @@ -912,8 +912,10 @@ server_client_msg_identify( return; } - if (!isatty(fd)) - return; + if (!isatty(fd)) { + close(fd); + return; + } data-term[(sizeof data-term) - 1] = '\0'; tty_init(c-tty, c, fd, data-term); if (data-flags IDENTIFY_UTF8) On Wed, Sep 26, 2012 at 01:40:53PM +0200, S?bastien Marie wrote: Hi, After some tests (on a new tmux server, started with tmux -L test ...), I could (partially) reproduce the problem. Partially, because: in fstat output there are 2 kinds of bugged entries: tty and null tty: 181 descriptors null: 320 descriptors And I arrived to keep descriptors opened against /dev/tty , but not against /dev/null (for the moment, but I monitor what in my use what generate this...). This occurs with urlview (textproc/urlview), with a custom url_handler. Basically urlview take a text in stdin (generally an email), and display a menu (ncurses) of URLs found in the text. The user choose an URL, and urlview start a command (in my case, a custom script). First, my configuration: $ cat ~/.urlview # command to invoke for selected URL COMMAND /home/semarie/.local/bin/urlview_handler.sh Next, the command started by urlview: $ cat /home/semarie/.local/bin/urlview_handler.sh #!/bin/sh # if TMUX enable, update environment if [ -n ${TMUX} ] ; then eval `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$/=\\1\/'` unset `tmux show-environment | grep'^-' | sed 's/^-//'` export `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$//'` fi # check DISPLAY if [ -n ${DISPLAY} ] ; then exec chrome $@ fi # if not DISPLAY exec lynx $@ And when I launch the command: $ echo 'http://www.openbsd.org/' | urlview 3 new descriptors against tty are opened and not closed after the command. There are directly correlate with the 3 tmux show-environment in the script. I don't remind exactly the purpose of updating the environnement in the script... should be to keep kerberos ticket or display environnement in text-mode ... but ? Additionnaly, running the url_hander alone (without urlview) don't trigger the problem. I will disabling the part of updating environment in my script (and if I always need it, I will recall when something won't work !) I will post when I have more info. Please let me known if more informations are needed. Thanks. -- Sebastien Marie
Re: tmux: create window failed (too many open files)
The patch seems to resolv the problem. Only seems, because I only known to reproduce it for the 'tty' descriptor, but I hope the 'null' descriptor will be in the same case :-) But I will use this version for test it. Thanks a lot. -- Sebastien Marie On Wed, Sep 26, 2012 at 03:42:23PM +0100, Nicholas Marriott wrote: Try this please: Index: server-client.c === RCS file: /cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.79 diff -u -p -r1.79 server-client.c --- server-client.c 3 Sep 2012 09:32:38 - 1.79 +++ server-client.c 26 Sep 2012 14:42:04 - @@ -912,8 +912,10 @@ server_client_msg_identify( return; } - if (!isatty(fd)) - return; + if (!isatty(fd)) { + close(fd); + return; + } data-term[(sizeof data-term) - 1] = '\0'; tty_init(c-tty, c, fd, data-term); if (data-flags IDENTIFY_UTF8) On Wed, Sep 26, 2012 at 01:40:53PM +0200, S?bastien Marie wrote: Hi, After some tests (on a new tmux server, started with tmux -L test ...), I could (partially) reproduce the problem. Partially, because: in fstat output there are 2 kinds of bugged entries: tty and null tty: 181 descriptors null: 320 descriptors And I arrived to keep descriptors opened against /dev/tty , but not against /dev/null (for the moment, but I monitor what in my use what generate this...). This occurs with urlview (textproc/urlview), with a custom url_handler. Basically urlview take a text in stdin (generally an email), and display a menu (ncurses) of URLs found in the text. The user choose an URL, and urlview start a command (in my case, a custom script). First, my configuration: $ cat ~/.urlview # command to invoke for selected URL COMMAND /home/semarie/.local/bin/urlview_handler.sh Next, the command started by urlview: $ cat /home/semarie/.local/bin/urlview_handler.sh #!/bin/sh # if TMUX enable, update environment if [ -n ${TMUX} ] ; then eval `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$/=\\1\/'` unset `tmux show-environment | grep'^-' | sed 's/^-//'` export `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$//'` fi # check DISPLAY if [ -n ${DISPLAY} ] ; then exec chrome $@ fi # if not DISPLAY exec lynx $@ And when I launch the command: $ echo 'http://www.openbsd.org/' | urlview 3 new descriptors against tty are opened and not closed after the command. There are directly correlate with the 3 tmux show-environment in the script. I don't remind exactly the purpose of updating the environnement in the script... should be to keep kerberos ticket or display environnement in text-mode ... but ? Additionnaly, running the url_hander alone (without urlview) don't trigger the problem. I will disabling the part of updating environment in my script (and if I always need it, I will recall when something won't work !) I will post when I have more info. Please let me known if more informations are needed. Thanks. -- Sebastien Marie
Re: tmux: create window failed (too many open files)
ok, I found why I have some 'null' descriptors... it nears the same case that with 'tty' descriptors. I have a custom script (again) for X11 locking, that first destroy kerberos tickets. And I use tmux show-environment for get KRB5CCNAME environment variable that I used in the tmux session. As the script is run by cwm, the input descriptor should be /dev/null. The patch resolvs all the problem. For simple test, this command could be used: $ tmux info /dev/null This will dup the descriptor in the tmux server, and it will not close it. So after some time, too many descriptors are opened... Thanks again. -- Sebastien Marie On Wed, Sep 26, 2012 at 05:19:56PM +0200, Sébastien Marie wrote: The patch seems to resolv the problem. Only seems, because I only known to reproduce it for the 'tty' descriptor, but I hope the 'null' descriptor will be in the same case :-) But I will use this version for test it. Thanks a lot. -- Sebastien Marie On Wed, Sep 26, 2012 at 03:42:23PM +0100, Nicholas Marriott wrote: Try this please: Index: server-client.c === RCS file: /cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.79 diff -u -p -r1.79 server-client.c --- server-client.c 3 Sep 2012 09:32:38 - 1.79 +++ server-client.c 26 Sep 2012 14:42:04 - @@ -912,8 +912,10 @@ server_client_msg_identify( return; } - if (!isatty(fd)) - return; + if (!isatty(fd)) { + close(fd); + return; + } data-term[(sizeof data-term) - 1] = '\0'; tty_init(c-tty, c, fd, data-term); if (data-flags IDENTIFY_UTF8)