Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SIGHUP wrapper
This works:
ssh linux.p 'eval `echo $SHELL | grep "/t\{0,1\}csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\; PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' tty\ \>/dev/null\ \&\&\ stty\ isig\ -onlcr\ -echo\;perl\ -e\ \'\ use\ IO::Poll\;\ \$SIG\{CHLD\}\ =\ sub\ \{\$done\ =\ 1\}\;\ \$p\ =\ IO::Poll-\>new\;\ \$p-\>mask\(STDOUT,\ POLLHUP\)\;\ \$pid=fork\;\ unless\(\$pid\)\ \{setpgrp\;\ exec\ \$ENV\{SHELL\},\ \"-c\",\ @ARGV\;\ die\ \"exec:\ \$\!\\n\"\}\ \$p-\>poll\;\ kill\ SIGHUP,\ -\$pid\ unless\ \$done\;\ wait\;\ exit\ \(\$\?\&127\ \?\ 128+\(\$\?\&127\)\ :\ 1+\$\?\>\>8\)\ \'\ echo\\\ OK\\\;ls\\\ output_to_STDERR\\\ ;
This blocks (does not finish):
ssh solaris.p 'eval `echo $SHELL | grep "/t\{0,1\}csh" > /dev/null && echo setenv PARALLEL_SEQ '$PARALLEL_SEQ'\; setenv PARALLEL_PID '$PARALLEL_PID' || echo PARALLEL_SEQ='$PARALLEL_SEQ'\;export PARALLEL_SEQ\; PARALLEL_PID='$PARALLEL_PID'\;export PARALLEL_PID` ;' tty\ \>/dev/null\ \&\&\ stty\ isig\ -onlcr\ -echo\;perl\ -e\ \'\ use\ IO::Poll\;\ \$SIG\{CHLD\}\ =\ sub\ \{\$done\ =\ 1\}\;\ \$p\ =\ IO::Poll-\>new\;\ \$p-\>mask\(STDOUT,\ POLLHUP\)\;\ \$pid=fork\;\ unless\(\$pid\)\ \{setpgrp\;\ exec\ \$ENV\{SHELL\},\ \"-c\",\ @ARGV\;\ die\ \"exec:\ \$\!\\n\"\}\ \$p-\>poll\;\ kill\ SIGHUP,\ -\$pid\ unless\ \$done\;\ wait\;\ exit\ \(\$\?\&127\ \?\ 128+\(\$\?\&127\)\ :\ 1+\$\?\>\>8\)\ \'\ echo\\\ OK\\\;ls\\\ output_to_STDERR\\\ ;
It blocks on these platforms (uname -a):
SunOS solaris 5.10 Generic_147147-26 sun4u sparc SUNW,Sun-Fire-V210
IRIX64 irix 6.5 07202013 IP35
AIX aix7 1 7 000ACFDE4C00
Linux centos.polarhome.com 2.6.18-371.6.1.el5 #1 SMP Wed Mar 12 20:03:51 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
SunOS openindiana 5.11 oi_148 i86pc i386 i86pc
OSF1 tru64.polarhome.com V5.1 2650 alpha
It works on these platforms (uname -a):
Linux debian 2.6.32-5-amd64 #1 SMP Mon Sep 23 22:14:43 UTC 2013 x86_64 GNU/Linux
Linux mandriva.polarhome.com 2.6.33.7-desktop-2mnb #1 SMP Mon Sep 20 18:19:20 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
GNU hurd 0.5 GNU-Mach 1.4-486/Hurd-0.5 i686-AT386 GNU
NetBSD netbsd.polarhome.com 6.1.3 NetBSD 6.1.3 (GENERIC) i386
MirBSD miros.polarhome.com 10 Kv#10uAF-20110818 GENERIC#1330 i386
OpenBSD openbsd.polarhome.com 4.9 GENERIC#671 i386
QNX qnx 6.5.0 2010/07/09-14:44:03EDT x86pc x86
FreeBSD freebsd.polarhome.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri May 6 13:20:42 CEST 2011 root@freebsd.polarhome.com:/usr/obj/usr/src/sys/POLARHOME amd64
Linux raspberrypi 3.2.27+ #307 PREEMPT Mon Nov 26 23:22:29 GMT 2012 armv6l GNU/Linux
SCO_SV scosysv 5 6.0.0 i386
UnixWare unixware 5 7.1.4 i386 x86at SCO UNIX_SVR5
Linux suse 3.4.63-2.44-desktop #1 SMP PREEMPT Wed Oct 2 11:18:32 UTC 2013 (d91a619) x86_64 x86_64 x86_64 GNU/Linux
Linux redhat.polarhome.com 3.9.10-100.fc17.x86_64 #1 SMP Sun Jul 14 01:31:27 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Linux ubuntu 3.2.0-64-generic #97-Ubuntu SMP Wed Jun 4 22:04:21 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
@ole-tange

This comment has been minimized.

Copy link
Owner Author

ole-tange commented Jun 21, 2014

Centos should be moved to working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.