Weird Control + C behaviour (closes ssh session)

Hi,

I recently upgraded one of my boxes to 10.2. This happens when I ssh into the machine. When I hit Control + C combination it goes to a new line like it is supposed to, however after I type any other command (like ls) and then do Control + C on the next line it just closes the ssh connection. If I have sudo root access, It downgrades to the user on the first one and closes connection on the second one.

Here is an example:
Code:
hostname$ sudo su
Password:
root@hostname:/usr/home/username #     <-- Ctrl + C
root@hostname:/usr/home/username #     <-- Ctrl + C
root@hostname:/usr/home/username # ls
.bash_history   .history   .mail_aliases   .shrc     mbox
.bashrc     .lesshst   .mailrc     .ssh     notes
.cshrc     .login     .profile   .vim 
.login_conf   .rhosts     .viminfo
root@hostname:/usr/home/username # hostname$ Connection to hostname.domainname closed.
The last line has two Ctrl + C as well which drops root first, then connection.

Do you guys have any idea why that might happen or how to fix it?
Thanks,
Leo

uname -a
Code:
FreeBSD hostname 10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC 2015  root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
 
Does this also happen if you ssh localhost, using this misbehaving box directly?
Does it happen with telnet?
With an account that uses plain-Jane /bin/sh?
Anything interesting when using ssh -vvv?

Juha
 
Oh, my bad. I should've added the shells as well. This happens with tcsh and csh. It doesn't happen with sh/bash. (Meaning when I change the shell to bash in the same session, it works normally and doesn't exit.)

It also happens with ssh localhost.

Here is the ssh -vvv output:
Code:
hostname$      <--- Ctrl + C
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

Connection to hostname.domainname closed.
Transferred: sent 3344, received 3040 bytes, in 4.7 seconds
Bytes per second: sent 704.5, received 640.4
debug1: Exit status 1

Thanks
 
The only difference between a normal connection close iI can see is the first couple of lines starting with rcvd eof line until rcvd eow line.

This is from sshd process:
Code:
select(8,{3 4},0x0,0x0,0x0)            ERR#4 'Interrupted system call'
SIGNAL 20 (SIGCHLD)
sigprocmask(SIG_SETMASK,SIGCHLD,0x0)        = 0 (0x0)
wait4(-1,{ EXITED,val=255 },WNOHANG,0x0)    = 52351 (0xcc7f)
wait4(-1,{ EXITED,val=-8 },WNOHANG,0x0)        = 0 (0x0)
sigprocmask(SIG_SETMASK,SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGABRT|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,SIGCHLD) = 0 (0x0)
sigaction(SIGCHLD,0x0,{ 0x803132080 SA_SIGINFO ss_t }) = 0 (0x0)
sigprocmask(SIG_SETMASK,SIGCHLD,0x0)        = 0 (0x0)
sigreturn(0x7fffffffd9e0,0x7fffffffd9e0,0x301,0x0,0xfffffffffffffbc0,0x804017010) ERR#4 'Interrupted system call'

This is from tcsh process:
Code:
read(16,0x7fffffffe292,1)            ERR#4 'Interrupted system call'
SIGNAL 2 (SIGINT)
sigprocmask(SIG_SETMASK,SIGINT,0x0)        = 0 (0x0)
process exit, rval = 1
 
I have a similar error. Don't know if it is the same. But not with ssh. It happens in csh and tcsh not in bash. I can interrupt a running command normal with Ctrl + C. But if I type a wrong line and type Ctrl+C it closes the tab in the terminal. (Sometime it terminates Conky and Firefox too - both in the same moment). I thought it is an error with my terminalemulator - lxterminal - or maybe keymap. May be interesting, I have the same system and terminal in vbox, and there it does not happen (same system 10.2 amd64, same keymap but no conky, also running keychain on login on both systems - maybe it an error of the combination of all this).
In the moment I use Ctrl+u if I type something wrong to delete the line instead of Ctrl+C.

=> And here is the question, does it terminate on your system the ssh connection or close it also only the tab (and with this the connection).

I should mention I have updated lxterminal to 0.2.0, recent version is 0.1.11_2. Btw, I have posted an update patch 2 months ago, the first post was not right, I have corrected it, but I don't understand why the maintainer not updated this port (no statement).
 
csh is reading the next character, gets interrupted by the pty, and... decides to just exit. Does it not know that it's interactive, or does it think the terminal is in raw mode and does not expect to receive terminal interrupt at that moment. Hairy...

Here's normal csh reaction for ^C. It has interrupts enabled ok.

Code:
read(16,0xbfbfe116,1)  ERR#4 'Interrupted system call'
SIGNAL 2 (SIGINT)
sigreturn(0xbfbfdde0,0x2,0x10006,0xbfbfdde0,0x0,0x808e600) ERR#4 'Interrupted system call'
sigprocmask(SIG_BLOCK,SIGINT,0x0)  = 0 (0x0)
ioctl(16,TIOCSETAW,0x809c01c)  = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)  = 0 (0x0)
stat("/etc/nsswitch.conf",{ mode=-rw-r--r-- ,inode=7144812,size=321,blksize=32768 }) = 0 (0x0)
stat("/etc/nsswitch.conf",{ mode=-rw-r--r-- ,inode=7144812,size=321,blksize=32768 }) = 0 (0x0)
write(17,"\r\n",2)  = 2 (0x2)
lseek(16,0x0,SEEK_END)  = 0 (0x0)
ioctl(15,TIOCSPGRP,0xbfbfe084)  = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)  = 0 (0x0)
write(17,"\^[[K",3)  = 3 (0x3)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
ioctl(16,FIONREAD,0xbfbfe174)  = 0 (0x0)
ioctl(16,TIOCGETA,0x809c04c)  = 0 (0x0)
ioctl(16,TIOCSETAW,0x809c078)  = 0 (0x0)
write(17,"% ",2)  = 2 (0x2)
Juha
 
I have to correct my post above: The killing of conky and firefox is in bash. The closing of the tab in csh and tcsh. It seems two different problems.
 
Check, if you have winbind references in /etc/nsswitch.conf and remove, if not needed. Helps for me.
Samba not configured properly in my case...

There is truss output from killed session (with 'windind' in passwd|group in /etc/nsswitch.conf)
Code:
command: truss -p 41516
read(16,"\n",1)                                  = 1 (0x1)
write(17,"\r\n",2)                               = 2 (0x2)
sigprocmask(SIG_BLOCK,SIGINT,0x0)                = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e620)                     = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
ioctl(16,TIOCGWINSZ,0xffffde88)                  = 0 (0x0)
sigprocmask(SIG_BLOCK,0x0,0x0)                   = 0 (0x0)
stat("/var/run/utx.active",{ mode=-rw-r--r-- ,inode=49175,size=1576,blksize=4096 }) = 0 (0x0)
open("/var/run/utx.active",O_CLOEXEC,0666)       = 0 (0x0)
fstat(0,{ mode=-rw-r--r-- ,inode=49175,size=1576,blksize=4096 }) = 0 (0x0)
fstat(0,{ mode=-rw-r--r-- ,inode=49175,size=1576,blksize=4096 }) = 0 (0x0)
read(0,"\^A\0\^E$a\f\M^G\M-,\M^A\0\0\0\0"...,985) = 985 (0x3d9)
read(0,"\a\0\^E$\M^R\M-8$&\M^B/5\0\0\0\0"...,985) = 591 (0x24f)
read(0,0x80185b800,985)                          = 0 (0x0)
close(0)                                         = 0 (0x0)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
ioctl(16,FIONREAD,0xffffdd24)                    = 0 (0x0)
ioctl(16,TIOCGETA,0x65e650)                      = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e680)                     = 0 (0x0)
write(17,"[\^[[1malex\^[[m(pts/1)@\^[[4msf"...,43) = 43 (0x2b)
read(16,0x7fffffffdca2,1)                        ERR#4 'Interrupted system call'
SIGNAL 2 (SIGINT)
sigprocmask(SIG_SETMASK,SIGINT,0x0)              = 0 (0x0)
sigreturn(0x7fffffffd240,0x7fffffffd240,0x301,0x0,0xfffffffffffffbc0,0x7c) ERR#4 'Interrupted system call'
sigprocmask(SIG_BLOCK,SIGINT,0x0)                = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e620)                     = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
stat("/etc/nsswitch.conf",{ mode=-rw-r--r-- ,inode=72157,size=327,blksize=4096 }) = 0 (0x0)
getpid()                                         = 41516 (0xa22c)
getpid()                                         = 41516 (0xa22c)
getpid()                                         = 41516 (0xa22c)
lstat("(null)",{ mode=drwxr-xr-x ,inode=69535,size=3,blksize=4096 }) = 0 (0x0)
lstat("/var/run/samba4/winbindd/pipe",{ mode=srwxrwxrwx ,inode=49224,size=0,blksize=4096 }) = 0 (0x0)
socket(PF_LOCAL,SOCK_STREAM,0)                   = 0 (0x0)
fcntl(0,F_DUPFD,0x3)                             = 3 (0x3)
close(0)                                         = 0 (0x0)
fcntl(3,F_GETFL,)                                = 2 (0x2)
fcntl(3,F_SETFL,O_NONBLOCK|0x2)                  = 0 (0x0)
fcntl(3,F_GETFD,)                                = 0 (0x0)
fcntl(3,F_SETFD,FD_CLOEXEC)                      = 0 (0x0)
connect(3,{ AF_UNIX "/var/run/samba4/winbindd/pipe" },106) ERR#61 'Connection refused'
close(3)                                         = 0 (0x0)
write(17,"\r\n",2)                               = 2 (0x2)
lseek(16,0x0,SEEK_END)                           = 0 (0x0)
ioctl(15,TIOCSPGRP,0xffffdb1c)                   = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
stat("/var/run/utx.active",{ mode=-rw-r--r-- ,inode=49175,size=1576,blksize=4096 }) = 0 (0x0)
write(17,"\^[[K",3)                              = 3 (0x3)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
ioctl(16,FIONREAD,0xffffdd24)                    = 0 (0x0)
ioctl(16,TIOCGETA,0x65e650)                      = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e680)                     = 0 (0x0)
write(17,"[\^[[1malex\^[[m(pts/1)@\^[[4msf"...,43) = 43 (0x2b)
read(16,"l",1)                                   = 1 (0x1)
write(17,"l",1)                                  = 1 (0x1)
read(16,"s",1)                                   = 1 (0x1)
write(17,"s",1)                                  = 1 (0x1)
read(16,"\n",1)                                  = 1 (0x1)
write(17,"\r\n",2)                               = 2 (0x2)
sigprocmask(SIG_BLOCK,SIGINT,0x0)                = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e620)                     = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGCHLD,0x0)               = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGINT|SIGCHLD,SIGCHLD)    = 0 (0x0)
vfork()                                          = 41646 (0xa2ae)
sigprocmask(SIG_SETMASK,SIGCHLD,0x0)             = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGINT|SIGCHLD,0x0)        = 0 (0x0)
SIGNAL 20 (SIGCHLD)
sigsuspend(0x7fffffffd950,0x0,0x10,0x0,0xc,0x4e0) ERR#4 'Interrupted system call'
sigprocmask(SIG_SETMASK,SIGINT|SIGCHLD,0x0)      = 0 (0x0)
sigreturn(0x7fffffffcf80,0x7fffffffcf80,0x301,0x0,0xfffffffffffffbc0,0x4e0) ERR#4 'Interrupted system call'
wait4(-1,{ EXITED,val=0 },WNOHANG|WUNTRACED,{ u=0.000000,s=0.000709,in=2,out=0 }) = 41646 (0xa2ae)
wait4(-1,0x7fffffffd934,WNOHANG|WUNTRACED,0x7fffffffd8a0) ERR#10 'No child processes'
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
ioctl(15,TIOCSPGRP,0xffffd97c)                   = 0 (0x0)
ioctl(16,TIOCGWINSZ,0xffffde88)                  = 0 (0x0)
sigprocmask(SIG_BLOCK,0x0,0x0)                   = 0 (0x0)
stat("/var/run/utx.active",{ mode=-rw-r--r-- ,inode=49175,size=1576,blksize=4096 }) = 0 (0x0)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
ioctl(16,FIONREAD,0xffffdd24)                    = 0 (0x0)
ioctl(16,TIOCGETA,0x65e650)                      = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e680)                     = 0 (0x0)
write(17,"[\^[[1malex\^[[m(pts/1)@\^[[4msf"...,43) = 43 (0x2b)
read(16,0x7fffffffdca2,1)                        ERR#4 'Interrupted system call'
SIGNAL 2 (SIGINT)
sigprocmask(SIG_SETMASK,SIGINT,0x0)              = 0 (0x0)
process exit, rval = 1

truss output with 'windind' disabled in passwd|group in /etc/nsswitch.conf
Code:
write(17,"[\^[[1malex\^[[m(pts/1)@\^[[4msf"...,43) = 43 (0x2b)
read(16,0x7fffffffdca2,1)                        ERR#4 'Interrupted system call'
SIGNAL 2 (SIGINT)
sigreturn(0x7fffffffd6c0,0x10006,0x7fffffffd6c0,0x68,0x801956000,0x7c) ERR#4 'Interrupted system call'
sigprocmask(SIG_BLOCK,SIGINT,0x0)                = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e620)                     = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
stat("/etc/nsswitch.conf",{ mode=-rw-r--r-- ,inode=72189,size=327,blksize=4096 }) = 0 (0x0)
write(17,"\r\n",2)                               = 2 (0x2)
lseek(16,0x0,SEEK_END)                           = 0 (0x0)
ioctl(15,TIOCSPGRP,0xffffdb1c)                   = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
stat("/var/run/utx.active",{ mode=-rw-r--r-- ,inode=49175,size=1576,blksize=4096 }) = 0 (0x0)
write(17,"\^[[K",3)                              = 3 (0x3)
setitimer(0,{0.000000, 0.000000 },{0.000000, 0.000000 }) = 0 (0x0)
ioctl(16,FIONREAD,0xffffdd24)                    = 0 (0x0)
ioctl(16,TIOCGETA,0x65e650)                      = 0 (0x0)
ioctl(16,TIOCSETAW,0x65e680)                     = 0 (0x0)
write(17,"[\^[[1malex\^[[m(pts/1)@\^[[4msf"...,43) = 43 (0x2b)
...
 
Was any of you guys able to somehow fix this behaviour ? I have the exact same problem with net/nss_ldap :( If I remove it from /etc/nsswitch.conf, everything works fine (apart from login of LDAP users apparently). If it's there, LDAP users are able to log in, but any Ctrl+C after any command causes the user to logout (so it's not a su(1) related issue). Has any of you opened any ticket for this (so far I have found none, so I would like to ask before opening one myself) ?

Thank you
 
I'm experiencing the same issue with both SSH and console sessions and I also use nss_ldap. The problem also happens with unix users like root. I should also note that if I switch to zsh which I installed though ports CTRL+c works as it should.
 
Funny thing is, that on 10.2-RELEASE without any updates (fresh install from a disk1 ISO) it works like a charm. after running # freebsd-update and rebooting... bang. and that is the only difference. after running # freebsd-update rollback everything works again as supposed to... :/
 
What does ps axosid,tsid,pgid,tpgid,tt,pid,comm|sort -n show in those strange situations?

Juha

I logged in and executed su - and afterwards ls. After Ctrl+C I was thrown back to the original user ('logged out' from su).

% ps axosid,tsid,pgid,tpgid,tt,pid,comm|sort -n
Code:
  SID  TSID  PGID TPGID TT    PID COMMAND
23922     0 23922     0  -  23925 sshd
23926 23926 23926 26057  0  23926 tcsh
23926 23926 26057 26057  0  26057 ps
23926 23926 26057 26057  0  26058 sort
 
Also, does stty -a (or stty -e if you prefer) reveal anything interesting?

% stty -a

Code:
speed 9600 baud; 75 rows; 315 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
    brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
    lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
    status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;

% stty -e

Code:
speed 9600 baud; 75 rows; 315 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
    brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
discard dsusp   eof     eol     eol2    erase   erase2  intr    kill  
^O      ^Y      ^D      <undef> <undef> ^?      ^H      ^C      ^U    
lnext   min     quit    reprint start   status  stop    susp    time  
^V      1       ^\      ^R      ^Q      ^T      ^S      ^Z      0     
werase
^W
 
I'm experiencing the same issue with both SSH and console sessions and I also use nss_ldap. The problem also happens with unix users like root. I should also note that if I switch to zsh which I installed though ports CTRL+c works as it should.

By switching you mean running 'zsh', or changing the login shell for the user ? Changing login shell for the user does not help for me, running another shell (bash, zsh, ...) from within the session helps... (but obviously, this is not a solution :( )
 
Does this also happen if you ssh localhost, using this misbehaving box directly?
Yes

Does it happen with telnet?
No idea, but as it happens also with console login, and also with ssh from ports, I don't think it is ssh related at all


With an account that uses plain-Jane /bin/sh?
Yes

Anything interesting when using ssh -vvv?
No

 
Same problem. I have samba installed on that server, and configured winbind in nsswitch.conf. rRemove winbind from nsswitch.conf fixed this problem.
 
The problem with /rescue/csh starts with

Code:
+20150916:  p3  FreeBSD-EN-15:16.pw
+  FreeBSD-EN-15:17.libc
+  FreeBSD-EN-15:18.pkg
+
+  Fix regression in pw(8) when creating numeric users or groups.
+  [EN-15:16]
+
+  Fix libc handling of signals for multi-threaded processes.
+  [EN-15:17]
+
+  Implement pubkey support for pkg(7) bootstrap. [EN-15:18]
+

At the moment I cannot check this with winbind easily.
 
so that would assume the problem is related to vfork (vfork()), as spwaning tcsh/csh with -F (-F The shell uses fork(2) instead of vfork(2) to spawn processes) works as a charm... :/
 
Hi,
I also have the same problem on several 10.3-RELEASE from -p3 to -p7 with winbind in nsswitch.conf.
Is it possible to create a fake /usr/local/bin/csh to call true csh with -F option and changing default shell to it ?
Executing csh -F just after ssh login or after sudo'ing did the trick, but it's not very friendly.
There are known bugs PR 125185 andPR 208132.
 
Back
Top