chiark / gitweb /
server/tests.at: Work around strace's attempt to overwrite core files.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 20 Jan 2012 01:23:41 +0000 (01:23 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 24 Jan 2012 01:49:21 +0000 (01:49 +0000)
When strace sees its child process die from a signal, it sends itself
the same signal in order to propagate the exit status accurately.
Unfortunately, if the child process left a core dump, it gets
overwritten by a useless core dump showing how strace committed suicide.

Work around this by running strace in a subdirectory and getting the
child process to run back in the parent.

Also see Debian bug #656389.

server/tests.at

index 4fcd9cd2abb714b29bae9048703fbc1a2115ebcc..188d65041a2696a6f5a058c747762120c6276928 100644 (file)
@@ -70,11 +70,19 @@ while test ! -r $1/server-status && test ! -S $1/admin; do :; done
 ## Test body...
 $3
 
-## End of the test, now run the server.
+## End of the test, now run the server.  There's an awful hack here.  If a
+## process running under strace exits with a signal, then strace will kill
+## itself with the same signal -- and therefore clobber the original
+## process's core file.  So we arrange to run strace in one directory and
+## have the child process run in another.
 ) && :; } | {
   cd $1
+  mkdir -p strace-hack/
   echo TRIPE $2 >&2
-  strace -f -o tripe.trace TRIPE $2 >server-output 2>server-errors
+  (cd strace-hack/
+   ulimit -c hard >/dev/null 2>&1
+   strace -f -o ../tripe.trace \
+     TRIPE -d.. $2 >../server-output 2>../server-errors)
   stat=$?
   echo $stat >server-status
   if test $stat -ne 0; then