[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Spuriously failing hook scripts

From: berni <bernhard_heibler_at_gmx.de>
Date: 2006-09-13 14:59:19 CEST

Hello,

I have the same problem on a Dual Xeon Workstation running SUSE 10.0.
What a coincident I debugged into the problem today. I came to the same
result. Handling the NOCHILD problem is a good idea because you get a
proper error message.
But to solve the problem I think it would be a good thing to disable
the SIGCHLD handler using apr_signal while the hook runs. I just made
the following changes to my version 1.3.2. Until now it seams to work
...

Any comments
Bernhard.

--- hooks.c.org 2006-09-13 14:46:33.000000000 +0200
+++ hooks.c 2006-09-13 14:47:21.000000000 +0200
@@ -21,6 +21,7 @@

 #include <apr_pools.h>
 #include <apr_file_io.h>
+#include <apr_signal.h>

 #include "svn_error.h"
 #include "svn_path.h"
@@ -58,7 +59,8 @@ run_hook_cmd (const char *name,
   int exitcode;
   apr_exit_why_e exitwhy;
   apr_proc_t cmd_proc;
-
+ apr_sigfunc_t * oldSigFunc;
+
   /* Create a pipe to access stderr of the child. */
   apr_err = apr_file_pipe_create(&read_errhandle, &write_errhandle,
pool);
   if (apr_err)
@@ -92,6 +94,8 @@ run_hook_cmd (const char *name,
     return svn_error_wrap_apr
       (apr_err, _("Can't create null stdout for hook '%s'"), cmd);

+ oldSigFunc = apr_signal(SIGCHLD, SIG_DFL);
+
   err = svn_io_start_cmd (&cmd_proc, ".", cmd, args, FALSE,
                           stdin_handle, null_handle, write_errhandle,
pool);

@@ -101,8 +105,12 @@ run_hook_cmd (const char *name,
      pipe so we don't hang on the read end later, if we need to read
it. */
   apr_err = apr_file_close (write_errhandle);
   if (!err && apr_err)
+ {
+ apr_signal(SIGCHLD, oldSigFunc);
+
     return svn_error_wrap_apr
       (apr_err, _("Error closing write end of stderr pipe"));
+ }

   if (err)
     {
@@ -117,6 +125,7 @@ run_hook_cmd (const char *name,
       err2 = svn_stringbuf_from_aprfile (&error, read_errhandle,
pool);

       err = svn_io_wait_for_cmd(&cmd_proc, cmd, &exitcode, &exitwhy,
pool);
+
       if (! err)
         {
           if (! APR_PROC_CHECK_EXIT (exitwhy) || exitcode != 0)
@@ -145,6 +154,9 @@ run_hook_cmd (const char *name,
         }
     }

+ apr_signal(SIGCHLD, oldSigFunc);
+
+
   /* Hooks are fallible, and so hook failure is "expected" to occur at
      times. When such a failure happens we still want to close the
pipe
      and null file */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Sep 14 00:21:28 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.