Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On an iMac running Snow Leopard I can open a terminal window and start a 'screen' session with no issues. However, if I ssh into the same machine (from elsewhere or locally) and then try to start a 'screen' session, it just hangs. No output at all. It won't respond to Ctrl-d, Ctrl-c etc. and has to be killed via it's PID. A session created in a local terminal can be resumed from a ssh session. Does that help direct suspicion towards any config?

I suspect an issue with one of .bashrc, .profile etc., but don't know which applies in this situation, and haven't made any changes in that area recently. All this is done as the same user.

I'm 99% sure this worked not long ago, but I suppose there is a slim possibility that this scenario hasn't cropped up before for me.

In answer to Gilles questions below:

The environment variables are the same in both cases. Most are blank - only COLUMNS, LINES, HOME, PATH, SHELL and TERM were set.

In the hung state, screen isn't taking any input at all. When it is killed the parent shell receives any keyboard input intended for screen. It consumes no CPU time.

Watching the two screen processes that are started, the lower numbered one is doing the following:

$ sudo dtruss -p 1545
SYSCALL(args)        = return
sigreturn(0x7FFF5FBFEE80, 0x1E, 0x7FFF5FBFEE80)      = 0 Err#-2
__pthread_canceled(0x0, 0x0, 0x7FFF5FBFEF38)         = -1 Err#22
setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)       = 0 0
kill(0x60A, 0x0, 0x1)        = 0 0
sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)       = 0 0
sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)        = 0x0 0
sigsuspend(0x0, 0x0, 0x0)        = -1 Err#4
<repeats approx every 10s>

The higher numbered one only ever outputs:

$ sudo dtruss -p 1546
SYSCALL(args)        = return

The output of 'dtruss -f -p $pid_of_bash_that_starts_screen' with the duplication removed is:

1500/0x15a94:  write_nocancel(0x2, "s\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "c\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "c\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "r\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "r\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "e\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "e\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "e\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "e\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "n\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "n\352\277_\377\177\0", 0x1)      = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  fork()        = 1635 0
1500/0x15a94:  setpgid(0x663, 0x663, 0x5DD)      = 0 0
1500/0x15a94:  sigprocmask(0x3, 0x7FFF5FBFF9C8, 0x0)         = 0x0 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFFA8C, 0x7FFF5FBFFA88)      = 0x0 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFFA2C, 0x7FFF5FBFFA28)      = 0x0 0
1500/0x15a94:  ioctl(0xFF, 0x4004667A, 0x7FFF5FBFF97C)       = 0 0
1500/0x15a94:  ioctl(0xFF, 0x80047476, 0x7FFF5FBFF9FC)       = 0 0
1500/0x15a94:  sigprocmask(0x3, 0x7FFF5FBFFA28, 0x0)         = 0x0 0
1500/0x15a94:  sigprocmask(0x3, 0x7FFF5FBFFA88, 0x0)         = 0x0 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFFA8C, 0x7FFF5FBFFA88)      = 0x0 0
1635/0x1654c:  ioctl(0x3, 0x80086804, 0x7FFF5FBFD6A0)        = 0 0
1635/0x1654c:  close(0x3)        = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD590, 0x2, 0x7FFF5FBFD580)         = 0 0
1635/0x1654c:  bsdthread_register(0x7FFF82BA42FC, 0x7FFF82B84F18, 0x2000)        = 0 0
1635/0x1654c:  thread_selfid(0x7FFF82BA42FC, 0x7FFF82B84F18, 0x0)        = 91468 0
1635/0x1654c:  open_nocancel("/dev/urandom\0", 0x0, 0x7FFF705D1B60)      = 3 0
1635/0x1654c:  read_nocancel(0x3, "g\307\017\235\330=\212e\272\357o\351\207\365\207\0023Ra^\372\344z8\nf\253\205\335\177v\261\365\241pj\360rNW\333\344\331\300\250W\f\273O&<\232\257\034^\350!\n\351&\231P\\\025\0", 0x40)       = 64 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  mmap(0x0, 0x3000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x59000 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD410, 0x2, 0x7FFF5FBFD3D0)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD3D0, 0x2, 0x7FFF5FBFD468)         = 0 0
1635/0x1654c:  getpid(0x7FFF5FBFD360, 0x7FFFFFE00050, 0x0)       = 1635 0
1635/0x1654c:  open_nocancel("/dev/urandom\0", 0x0, 0x0)         = 3 0
1635/0x1654c:  read_nocancel(0x3, ":juq\236\223OW\305\231,\002\205\235E\346_\236>H\t\026=\213\220\\\020\tN?\240\254\361\262q<e\300M\252\200le<\241$\027\377\252Xs\034\355\212+#z+\241\033I\346s\017\227\244\351\227\024\272\361\263Qn\315\354U\312\211\017\313\265\f\033I\341\300\372Id\327\251tB\016\026/(\313\214\266\242S\275\351\372Y{\0", 0x6C)         = 108 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD410, 0x2, 0x7FFF5FBFD43C)         = 0 0
1635/0x1654c:  mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x5C000 0
1635/0x1654c:  mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x69000 0
1635/0x1654c:  mmap(0x0, 0x1000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x76000 0
1635/0x1654c:  mmap(0x0, 0x200000, 0x3, 0x1002, 0x7000000, 0x7FFF00000001)       = 0x77000 0
1635/0x1654c:  munmap(0x100077000, 0x89000)      = 0 0
1635/0x1654c:  munmap(0x100200000, 0x77000)      = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD570, 0x2, 0x7FFF5FBFD530)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD530, 0x2, 0x7FFF705DE6C0)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD570, 0x2, 0x7FFF5FBFD530)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD530, 0x2, 0x7FFF705DE6C4)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD570, 0x2, 0x7FFF5FBFD530)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD530, 0x2, 0x7FFF705DE6C8)         = 0 0
1635/0x1654c:  getdtablesize(0x0, 0x7FFF5FBFFA40, 0x0)       = 256 0
1635/0x1654c:  close(0xFF)       = -1 Err#9
...
1635/0x1654c:  close(0x3)        = -1 Err#9
1635/0x1654c:  getuid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x7FFF5FBFF3D1)       = 502 0
1635/0x1654c:  getgid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x0)      = 20 0
1635/0x1654c:  geteuid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x0)         = 502 0
1635/0x1654c:  getegid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x0)         = 20 0
1635/0x1654c:  sigaction(0x19, 0x7FFF5FBFF200, 0x7FFF5FBFF240)       = 0 0
1635/0x1654c:  sigaction(0xD, 0x7FFF5FBFF200, 0x7FFF5FBFF240)        = 0 0
1635/0x1654c:  access("/Users/chris/.nethackrc\0", 0x0, 0x17)        = -1 Err#2
1635/0x1654c:  getlogin(0x7FFF705D05A0, 0xFF, 0xFFFFFFFFFFFFFFFF)        = 0 0
1635/0x1654c:  mmap(0x0, 0x1000000, 0x3, 0x1002, 0x2000000, 0x100000000)         = 0x200000 0
1635/0x1654c:  munmap(0x100200000, 0x600000)         = 0 0
1635/0x1654c:  munmap(0x101000000, 0x200000)         = 0 0
1635/0x1654c:  shm_open(0x7FFF82CBF980, 0x0, 0x0)        = 3 0
1635/0x1654c:  mmap(0x0, 0x1000, 0x1, 0x1, 0x3, 0x100000000)         = 0x77000 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  getrlimit(0x1008, 0x7FFF5FBFEFF0, 0x7FFF82B6E86C)         = 0 0
1635/0x1654c:  open_nocancel("/etc/sysinfo.conf\0", 0x0, 0x1B6)      = -1 Err#2
1635/0x1654c:  stat64("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/\0", 0x7FFF5FBFED00, 0x0)         = 0 0
1635/0x1654c:  mkdir("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/-Tmp-/\0", 0x1C0, 0x7FFF5FBFEE13)      = -1 Err#17
1635/0x1654c:  access("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/-Tmp-/.screen\0", 0x0, 0x3C0)         = 0 0
1635/0x1654c:  stat64("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/-Tmp-/.screen\0", 0x7FFF5FBFF2C0, 0x0)        = 0 0
1635/0x1654c:  umask(0x12, 0x7FFF5FBFF2C0, 0x80808000)       = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFF110, 0x2, 0x7FFF5FBFF120)         = 0 0
1635/0x1654c:  sigaction(0x1, 0x7FFF5FBFF200, 0x7FFF5FBFF240)        = 0 0
1635/0x1654c:  fork()        = 1636 0
1635/0x1654c:  setgid(0x14, 0x7FFF5FBFF7F1, 0x10005364B)         = 0 0
1635/0x1654c:  setuid(0x1F6, 0x7FFF5FBFF7F1, 0x0)        = 0 0
1635/0x1654c:  sigaction(0x1, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  sigaction(0x1, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  sigaction(0x1E, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0x1F, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0x2, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  sigaction(0x12, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0x1C, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)         = 0x0 0
1636/0x1654e:  fstat64(0x2, 0x7FFF5FBFE5F0, 0x7FFF5FBFE6BC)      = 0 0
1636/0x1654e:  ioctl(0x2, 0x4004667A, 0x7FFF5FBFE63C)        = 0 0
1636/0x1654e:  write_nocancel(0x2, "SCREEN: can't detach from console\n\0", 0x22)        = 34 0
1635/0x1654c:  sigsuspend(0x0, 0x0, 0x0)         = -1 Err#4
1635/0x1654c:  __pthread_canceled(0x0, 0x0, 0x7FFF5FBFEF38)      = -1 Err#22
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  kill(0x664, 0x0, 0x1)         = 0 0
1635/0x1654c:  sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)         = 0x0 0
1500/0x15a94:  read(0x0, "\r\006\0", 0x1)        = 1 0
1500/0x15a94:  write_nocancel(0x2, "\n\006\0", 0x1)      = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x1000A5984, 0x1000A5988)        = 0x0 0
1500/0x15a94:  ioctl(0x0, 0x80487414, 0x1000A59C0)       = 0 0
1500/0x15a94:  sigprocmask(0x3, 0x1000A5988, 0x0)        = 0x0 0
1500/0x15a94:  sigaction(0x2, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0xF, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0x3, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0xE, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0x12, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x16, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x15, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x1C, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x2, 0x7FFF5FBFEB00, 0x7FFF5FBFEB30)        = 0 0
1500/0x15a94:  gettimeofday(0x7FFF5FBFE9D0, 0x0, 0x1F80)         = 1289128377 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFF9CC, 0x7FFF5FBFF9C8)      = 0x0 0
1635/0x1654c:  fork()        = 0 0
1635/0x1654c:  thread_selfid(0x7FFF705D4C20, 0x3, 0x1)       = 91468 0
1635/0x1654c:  getpid(0x7FFF705D4C20, 0x3, 0x0)      = 1635 0
1635/0x1654c:  sigprocmask(0x3, 0x1000A69D8, 0x0)        = 0x0 0
1635/0x1654c:  sigaction(0x12, 0x7FFF5FBFF950, 0x7FFF5FBFF980)       = 0 0
1635/0x1654c:  sigaction(0x15, 0x7FFF5FBFF950, 0x7FFF5FBFF980)       = 0 0
1635/0x1654c:  sigaction(0x16, 0x7FFF5FBFF960, 0x7FFF5FBFF990)       = 0 0
1635/0x1654c:  setpgid(0x663, 0x663, 0x0)        = 0 0
1635/0x1654c:  sigprocmask(0x1, 0x7FFF5FBFF98C, 0x7FFF5FBFF988)      = 0x0 0
1635/0x1654c:  ioctl(0xFF, 0x4004667A, 0x7FFF5FBFF8DC)       = 0 0
1635/0x1654c:  ioctl(0xFF, 0x80047476, 0x7FFF5FBFF95C)       = 0 0
1635/0x1654c:  sigprocmask(0x3, 0x7FFF5FBFF988, 0x0)         = 0x0 0
1635/0x1654c:  sigaction(0x2, 0x7FFF5FBFF950, 0x7FFF5FBFF980)        = 0 0
1635/0x1654c:  sigaction(0x3, 0x7FFF5FBFF950, 0x7FFF5FBFF980)        = 0 0
1635/0x1654c:  sigaction(0xF, 0x7FFF5FBFF950, 0x7FFF5FBFF980)        = 0 0
1635/0x1654c:  sigaction(0x14, 0x7FFF5FBFF950, 0x7FFF5FBFF980)       = 0 0
1635/0x1654c:  execve(0x1001D0C30, 0x1001D0D20, 0x1001CFC40)         = 0 0
1635/0x1654c:  gettimeofday(0x7FFF5FBFF850, 0x0, 0x7FFF5FBFFA50)         = 1289128377 0
1635/0x1654c:  getpid(0x7FFF5FBFF850, 0x0, 0x0)      = 1635 0
1635/0x1654c:  open_nocancel("/dev/urandom\0", 0x0, 0x0)         = 3 0
1635/0x1654c:  read_nocancel(0x3, "\021M\323J\242\363\227\001py\363h\331\321)\326\216\300r\n9r\b\252g\342\326\003\242\340\246\311\0", 0x6C)      = 108 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  issetugid(0x100000000, 0x7FFF5FBFFB18, 0x7FFF5FC40530)        = 0 0
1635/0x1654c:  geteuid(0x100000000, 0x7FFF5FBFFB18, 0x0)         = 502 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD740, 0x2, 0x7FFF5FBFD700)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD700, 0x2, 0x7FFF5FBFD79C)         = 0 0
1635/0x1654c:  shared_region_check_np(0x7FFF5FBFD908, 0x0, 0x7FFF5FC1DC86)       = 0 0
1635/0x1654c:  stat64("/Applications/ImageMagick/lib/libncurses.5.4.dylib\0", 0x7FFF5FBFCE50, 0x7FFF5FBFD0F0)        = -1 Err#2
1635/0x1654c:  stat64("/usr/lib/libncurses.5.4.dylib\0", 0x7FFF5FBFCAB0, 0x7FFF5FBFD0F0)         = 0 0
1635/0x1654c:  stat64("/Applications/ImageMagick/lib/libSystem.B.dylib\0", 0x7FFF5FBFCE50, 0x7FFF5FBFD0F0)       = -1 Err#2
1635/0x1654c:  stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF5FBFCAB0, 0x7FFF5FBFD0F0)        = 0 0
1635/0x1654c:  stat64("/Applications/ImageMagick/lib/libmathCommon.A.dylib\0", 0x7FFF5FBFCBB0, 0x7FFF5FBFCE50)       = -1 Err#2
1635/0x1654c:  stat64("/usr/lib/system/libmathCommon.A.dylib\0", 0x7FFF5FBFC810, 0x7FFF5FBFCE50)         = 0 0
1635/0x1654c:  madvise(0x7FFF89561000, 0x2000, 0x5)      = 0 0
1635/0x1654c:  open("/dev/dtracehelper\0", 0x2, 0x7FFF5FC451F8)      = 3 0
1635/0x1654c:  ioctl(0x0, 0x40487413, 0x7FFF5FBFF1E0)        = 0 0
1635/0x1654c:  fstat64(0x0, 0x7FFF5FBFF150, 0x0)         = 0 0
1635/0x1654c:  open_nocancel("/dev/\0", 0x100004, 0x0)       = 3 0
1635/0x1654c:  fcntl_nocancel(0x3, 0x2, 0x1)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFE5E0, 0x2, 0x7FFF705D6698)         = 0 0
1635/0x1654c:  fstatfs64(0x3, 0x7FFF5FBFE630, 0x0)       = 0 0
1635/0x1654c:  getdirentries64(0x3, 0x100801400, 0x1000)         = 3080 0
1635/0x1654c:  lstat64("/dev/.\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/..\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/console\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/tty\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/null\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/zero\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/klog\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/fd\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/stdin\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/stdout\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/stderr\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/auditpipe\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ttyp0\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ptyp0\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
...
1635/0x1654c:  lstat64("/dev/ttywf\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ptywf\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ptmx\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/vn0\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/vn1\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/vn2\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/vn3\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/bpf0\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/bpf1\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/bpf2\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/bpf3\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/fsevents\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/random\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/urandom\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/dtrace\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/dtracehelper\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/lockstat\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/sdt\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/systrace\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/machtrace\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/fbt\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/profile\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  getdirentries64(0x3, 0x100801400, 0x1000)         = 888 0
1635/0x1654c:  lstat64("/dev/pmCPUClient\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/disk0\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/rdisk0\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/disk0s1\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/rdisk0s1\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/disk0s2\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/rdisk0s2\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/io8log\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/io8logmt\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/cu.Bluetooth-Modem\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/tty.Bluetooth-Modem\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/cu.W880i-SerialPort\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/tty.W880i-SerialPort\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/cu.Bluetooth-PDA-Sync\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/tty.Bluetooth-PDA-Sync\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/autofs\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/autofs_nowait\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/autofs_control\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/ttys000\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/ttys002\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  stat64("/dev/ttys002\0", 0x7FFF5FBFF2C0, 0x7FFF705D03A0)      = 0 0
1635/0x1654c:  seteuid(0x1F6, 0x6, 0x0)      = 0 0
1635/0x1654c:  setegid(0x14, 0x6, 0x0)       = 0 0
1635/0x1654c:  open("/dev/ttys002\0", 0x6, 0x0)      = 3 0
1635/0x1654c:  seteuid(0x1F6, 0x6, 0x0)      = 0 0
1635/0x1654c:  setegid(0x14, 0x6, 0x0)       = 0 0
1635/0x1654c:  close(0x3)        = 0 0
1635/0x1654c:  ioctl(0x0, 0x40487413, 0x100053C20)       = 0 0
1635/0x1654c:  umask(0x0, 0x40487413, 0x0)       = 18 0
1635/0x1654c:  geteuid(0x1, 0x7FFF5FBFEDE0, 0x400)       = 502 0
1636/0x1654e:  fork()        = 0 0
1636/0x1654e:  thread_selfid(0x7FFF705D4C20, 0x3, 0x1)       = 91470 0
1636/0x1654e:  getpid(0x7FFF705D4C20, 0x3, 0x0)      = 1636 0
1636/0x1654e:  seteuid(0x1F6, 0x2, 0x0)      = 0 0
1636/0x1654e:  setegid(0x14, 0x2, 0x0)       = 0 0
1636/0x1654e:  open("/dev/ttys002\0", 0x2, 0x0)      = 3 0
1636/0x1654e:  seteuid(0x1F6, 0x2, 0x0)      = 0 0
1636/0x1654e:  setegid(0x14, 0x2, 0x0)       = 0 0
1636/0x1654e:  close_nocancel(0x0)       = 0 0
1636/0x1654e:  open_nocancel("/dev/null\0", 0x0, 0x1B6)      = 0 0
1636/0x1654e:  close_nocancel(0x1)       = 0 0
1636/0x1654e:  open_nocancel("/dev/null\0", 0x601, 0x1B6)        = 1 0
1636/0x1654e:  close_nocancel(0x2)       = 0 0
1636/0x1654e:  open_nocancel("/dev/null\0", 0x601, 0x1B6)        = 2 0
1636/0x1654e:  audit_session_self(0x664, 0x7FFF5FBFF228, 0x7FFF82B6B366)         = 2563 0
1635/0x1654c:  sigsuspend(0x0, 0x0, 0x0)         = -1 Err#4
1635/0x1654c:  sigreturn(0x7FFF5FBFEE80, 0x1E, 0x7FFF5FBFEE80)       = 0 Err#-2
1635/0x1654c:  __pthread_canceled(0x0, 0x0, 0x7FFF5FBFEF38)      = -1 Err#22
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  kill(0x664, 0x0, 0x1)         = 0 0
1635/0x1654c:  sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)         = 0x0 0
share|improve this question
    
Compare the values of the environment variables listed in the “environment” section of the screen manual when in a local terminal and over ssh. When screen hangs, does Ctrl+a d provoke any response? Watch the screen process from another terminal: is it consuming CPU time? Also try watching the screen process with dtruss -p 12345 where 12345 is the process ID (you need to be root). –  Gilles Nov 5 '10 at 22:19
    
I've added answers to those questions above, to allow better formatting. –  Chris Nov 7 '10 at 11:08
    
Do you have a .screenrc? (If you do, try without it.) Now here are a few things to try in the ssh session: screen bash; screen ls; become root and run screen; become root and run dtruss screen. –  Gilles Nov 7 '10 at 17:13
    
It was when trying a .screenrc for the first time (to display tabs along the bottom line) that I discovered the problem. Removing the file makes no difference. Trying with a new user account for the first time, that had the same issues. I've captured the output from dtruss for the two cases and they inevitably differ wildly, but from a surprisingly early point. The working case does an lstat64() on a bunch of /dev/{p,t}tytN (N=6,7,8,9,A) and then a stat64(), mkdir(), access() and another stat64() inside my $TMPDIR. There's then reading of terminfo etc. before they converge with an ioctl(). –  Chris Nov 8 '10 at 12:00
    
I've added 'dtruss' output of the failing case to the question. The working case is available if required, but it's 2300 lines long. –  Chris Nov 8 '10 at 16:01

1 Answer 1

up vote 4 down vote accepted

You are not the only one with this problem. Screen hangs in an Apple-specific bit of code. It seems that if you take out this bit of code and recompile, it works.

  • You need to have the Apple development tools (Xcode) installed.
  • Download the screen source. (There is a more recent version, screen-19, where you'll have to take out the offending code by hand in screen.c.) Then unpack it:

    tar -xzf screen-16.tar.gz
    cd screen-16
    
  • Take out the first and third chunks of the patch to screen.c; that is, patches/screen.c.diff should now contain

    --- screen.c    2003-09-08 07:26:41.000000000 -0700
    +++ screen.c    2009-02-13 12:05:05.000000000 -0800
    @@ -929,6 +934,16 @@
        Panic(0, "No $SCREENDIR with multi screens, please.");
     #endif
         }
    +#ifdef __APPLE__
    +    else if (!multi && real_uid == eff_uid) {
    +      static char DarwinSockDir[PATH_MAX];
    +      if (confstr(_CS_DARWIN_USER_TEMP_DIR, DarwinSockDir, sizeof(DarwinSockDir))) {
    +   strlcat(DarwinSockDir, ".screen", sizeof(DarwinSockDir));
    +   SockDir = DarwinSockDir;
    +      }
    +    }
    +#endif /* __APPLE__ */
    +
     #ifdef MULTIUSER
       if (multiattach)
         {
    
  • Now compile the code:

    make install_source
    make
    
  • Check that the resulting executable /tmp/screen/Build/screen works.

  • See D4T3N7OD's blog for how to replace the official screen executable by yours.

I have no idea why screen hangs, why the fix above works, and what you lose by removing this bit of patch. In case anyone is interested, here's how far I went tracing down the code.

  • Screen forks a child process, which freezes after opening /dev/null on std{in,out,err} and calling audit_session_self. The corresponding place in the source is in screen.c, where we see a call to a private Apple API:

    #if defined(__APPLE__) && !TARGET_OS_EMBEDDED
        if (_vprocmgr_detach_from_console(0) != NULL)
            errx(1, "can't detach from console");
    #endif
    
  • This code seems to originate from the Apple patch for screen 11.

  • The implementation of _vprocmgr_detach_from_console seems to be in libvproc, where it leads to

    task_name_for_pid(mach_task_self(), getpid(), &tnp);
    vproc_mig_switch_to_session(bootstrap_port, tnp, (char *)target_session, _audit_session_self(), &new_bsport))
    

    Here we recognize _audit_session_self, the last (Darwin) system call that worked.

  • Next up is the Mach call switch_to_session. This is where I lose track.

share|improve this answer
    
That sounds very promising, but it might be a day or two before I get chance to sit down and go through the process. Ideally 10.6.5 (due any day now?) will fix it properly, so I may wait to see if that makes a difference. Or am I being too optimistic? Anyway, thanks for chasing this one. –  Chris Nov 8 '10 at 22:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.