Skip to content

Terminal detection (color) fails in sshx #140

Description

@hellt

Hi @ekzhang

I am a longtime user of sshx, and I noticed that CLI apps that try to detect the CLI color capabilities fail to do so in sshx session.

When launching sshx without any flags, I get a session with xterm terminal:

❯ echo $TERM
xterm-256color

Then when I run my CLI tool that uses terminal detection to understand the color theme and color support it hangs for two 5s periods on pselect6

❯ strace -tt -f -e trace=write,pselect6 containerlab version
strace: Process 1782530 attached
strace: Process 1782531 attached
strace: Process 1782532 attached
strace: Process 1782533 attached
strace: Process 1782534 attached
strace: Process 1782535 attached
[pid 1782533] 14:13:15.589627 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
strace: Process 1782536 attached
[pid 1782529] 14:13:15.589780 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782536] 14:13:15.590628 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782536] 14:13:15.594521 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
strace: Process 1782537 attached
[pid 1782529] 14:13:15.595111 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782535] 14:13:15.595581 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782529] 14:13:15.595757 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782536] 14:13:15.596008 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782535] 14:13:15.596767 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782529] 14:13:15.596997 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
strace: Process 1782538 attached
[pid 1782536] 14:13:15.604097 write(2, "\33]10;?\33\\", 8) = 8
[pid 1782536] 14:13:15.604285 write(2, "\33[6n", 4) = 4
[pid 1782536] 14:13:15.604349 pselect6(3, [2], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 0 (Timeout)
[pid 1782536] 14:13:20.613026 write(2, "\33]11;?\33\\", 8) = 8
[pid 1782536] 14:13:20.613094 write(2, "\33[6n", 4) = 4
[pid 1782536] 14:13:20.613108 pselect6(3, [2], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 0 (Timeout)
[pid 1782536] 14:13:25.623182 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782538] 14:13:25.624041 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782537] 14:13:25.624122 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782536] 14:13:25.624144 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782535] 14:13:25.624165 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782534] 14:13:25.624228 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782531] 14:13:25.624309 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782532] 14:13:25.624374 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782529] 14:13:25.624439 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782530] 14:13:25.624460 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782531] 14:13:25.624665 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782538] 14:13:25.624866 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782537] 14:13:25.625009 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782536] 14:13:25.625076 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782535] 14:13:25.625235 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782534] 14:13:25.625308 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782532] 14:13:25.625429 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782531] 14:13:25.625589 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782530] 14:13:25.625716 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782529] 14:13:25.625889 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1782529, si_uid=501} ---
[pid 1782533] 14:13:25.626138 write(1, "  ____ ___  _   _ _____  _    __"..., 441  ____ ___  _   _ _____  _    ___ _   _ _____ ____  _       _     
 / ___/ _ \| \ | |_   _|/ \  |_ _| \ | | ____|  _ \| | __ _| |__  
| |  | | | |  \| | | | / _ \  | ||  \| |  _| | |_) | |/ _` | '_ \ 
| |__| |_| | |\  | | |/ ___ \ | || |\  | |___|  _ <| | (_| | |_) |
 \____\___/|_| \_| |_/_/   \_\___|_| \_|_____|_| \_\_|\__,_|_.__/ 

) = 441
[pid 1782533] 14:13:25.626492 write(1, "    version: 0.70.2\n", 20    version: 0.70.2
) = 20
[pid 1782533] 14:13:25.626699 write(1, "     commit: 4c7cab2c\n", 22     commit: 4c7cab2c
) = 22
[pid 1782533] 14:13:25.626908 write(1, "       date: 2025-09-25T12:23:38"..., 34       date: 2025-09-25T12:23:38Z
) = 34
[pid 1782533] 14:13:25.626992 write(1, "     source: https://github.com/"..., 54     source: https://github.com/srl-labs/containerlab
) = 54
[pid 1782533] 14:13:25.627099 write(1, " rel. notes: https://containerla"..., 52 rel. notes: https://containerlab.dev/rn/0.70/#0702
) = 52
[pid 1782538] 14:13:25.627399 +++ exited with 0 +++
[pid 1782536] 14:13:25.627418 +++ exited with 0 +++
[pid 1782537] 14:13:25.627442 +++ exited with 0 +++
[pid 1782531] 14:13:25.627445 +++ exited with 0 +++
[pid 1782530] 14:13:25.627446 +++ exited with 0 +++
[pid 1782535] 14:13:25.627451 +++ exited with 0 +++
[pid 1782534] 14:13:25.627453 +++ exited with 0 +++
[pid 1782532] 14:13:25.627472 +++ exited with 0 +++
[pid 1782533] 14:13:25.628904 +++ exited with 0 +++
14:13:25.628934 +++ exited with 0 +++

If I set the TERM=dumb, it works:

❯ TERM=dumb strace -tt -f -e trace=write,pselect6 containerlab version
strace: Process 1783699 attached
strace: Process 1783700 attached
strace: Process 1783701 attached
strace: Process 1783702 attached
strace: Process 1783703 attached
strace: Process 1783704 attached
strace: Process 1783705 attached
[pid 1783698] 14:16:02.631074 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783701] 14:16:02.631175 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.631279 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783704] 14:16:02.631565 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783704] 14:16:02.631850 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.632041 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.632531 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.632945 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.636692 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783703] 14:16:02.636828 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783705] 14:16:02.636856 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
strace: Process 1783706 attached
[pid 1783698] 14:16:02.637943 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783704] 14:16:02.638134 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.638227 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783701] 14:16:02.641022 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.641169 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783700] 14:16:02.641412 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
strace: Process 1783707 attached
[pid 1783698] 14:16:02.641442 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783700] 14:16:02.641712 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
strace: Process 1783708 attached
[pid 1783698] 14:16:02.641929 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783708] 14:16:02.643489 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783707] 14:16:02.643740 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783706] 14:16:02.643874 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783705] 14:16:02.644187 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783704] 14:16:02.644331 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783703] 14:16:02.644418 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783702] 14:16:02.644555 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783701] 14:16:02.644711 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783699] 14:16:02.644881 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.644995 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783708] 14:16:02.645562 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783707] 14:16:02.645692 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783706] 14:16:02.645903 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783705] 14:16:02.646096 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783704] 14:16:02.646340 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783703] 14:16:02.646530 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783702] 14:16:02.646764 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783701] 14:16:02.646904 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783699] 14:16:02.647149 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783698] 14:16:02.647314 --- SIGRT_1 {si_signo=SIGRT_1, si_code=SI_TKILL, si_pid=1783698, si_uid=501} ---
[pid 1783700] 14:16:02.647561 write(1, "  ____ ___  _   _ _____  _    __"..., 441  ____ ___  _   _ _____  _    ___ _   _ _____ ____  _       _     
 / ___/ _ \| \ | |_   _|/ \  |_ _| \ | | ____|  _ \| | __ _| |__  
| |  | | | |  \| | | | / _ \  | ||  \| |  _| | |_) | |/ _` | '_ \ 
| |__| |_| | |\  | | |/ ___ \ | || |\  | |___|  _ <| | (_| | |_) |
 \____\___/|_| \_| |_/_/   \_\___|_| \_|_____|_| \_\_|\__,_|_.__/ 

) = 441
[pid 1783700] 14:16:02.647638 write(1, "    version: 0.70.2\n", 20    version: 0.70.2
) = 20
[pid 1783700] 14:16:02.647664 write(1, "     commit: 4c7cab2c\n", 22     commit: 4c7cab2c
) = 22
[pid 1783700] 14:16:02.647709 write(1, "       date: 2025-09-25T12:23:38"..., 34       date: 2025-09-25T12:23:38Z
) = 34
[pid 1783700] 14:16:02.647720 write(1, "     source: https://github.com/"..., 54     source: https://github.com/srl-labs/containerlab
) = 54
[pid 1783700] 14:16:02.647745 write(1, " rel. notes: https://containerla"..., 52 rel. notes: https://containerlab.dev/rn/0.70/#0702
) = 52
[pid 1783708] 14:16:02.647949 +++ exited with 0 +++
[pid 1783706] 14:16:02.647964 +++ exited with 0 +++
[pid 1783701] 14:16:02.647966 +++ exited with 0 +++
[pid 1783705] 14:16:02.647967 +++ exited with 0 +++
[pid 1783700] 14:16:02.647968 +++ exited with 0 +++
[pid 1783704] 14:16:02.647969 +++ exited with 0 +++
[pid 1783707] 14:16:02.647974 +++ exited with 0 +++
[pid 1783703] 14:16:02.647975 +++ exited with 0 +++
[pid 1783702] 14:16:02.647977 +++ exited with 0 +++
[pid 1783699] 14:16:02.648860 +++ exited with 0 +++
14:16:02.648874 +++ exited with 0 +++

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions