Mon 18 Aug 2003 03:35:10 PM UTC, comment #1:
The patch again (to be viewed online) :
--- gsnd/gsnd.m~ 2002-07-30 23:19:05.000000000 +0200
+++ gsnd/gsnd.m 2003-08-14 07:36:43.000000000 +0200
@@ -24,6 +24,7 @@
#include "portaudio/pa_common/portaudio.h"
#include <math.h>
#include <unistd.h>
+#include <fcntl.h>
#ifdef _MINGW_
#include "process.h"
@@ -969,6 +970,8 @@
int main(int argc, char** argv, char **env)
{
+ int is_daemon = 1, c;
+
CREATE_AUTORELEASE_POOL(pool);
#ifdef GS_PASS_ARGUMENTS
@@ -1007,6 +1010,42 @@
}
#endif
+ /*
+ * Ensure we don't have any open file descriptors which may refer
+ * to sockets bound to ports we may try to use.
+ *
+ * Use '/dev/null' for stdin and stdout. Assume stderr is ok.
+ */
+ for (c = 0; c < FD_SETSIZE; c++)
+ {
+ if (is_daemon /|| (c != 2)/)
+ {
+ (void)close(c);
+ }
+ }
+ if (open("/dev/null", O_RDONLY) != 0)
+ {
+ NSLog(@"gsnd - failed to open stdin from /dev/null (%s)",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if (open("/dev/null", O_WRONLY) != 1)
+ {
+ NSLog(@"gsnd - failed to open stdout from /dev/null (%s)",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if (is_daemon && open("/dev/null", O_WRONLY) != 2)
+ {
+ NSLog(@"gsnd - failed to open stderr from /dev/null (%s)",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if (0)
+ {
+ NSLog(@"gsnd - Closed descriptors");
+ }
+
gsnd = [[SoundServer alloc] init];
if (gsnd == nil) {
@@ -1262,4 +1301,3 @@
NSLog([NSString stringWithCString: s]);
return -1;
}
-
|
Mon 18 Aug 2003 03:09:34 PM UTC, original submission:
When trying to autobuild packages wich depend on gnustep-gui0_0.8.8 for debian, gnustep_sndd hangs the debian build daemons.
Report from Ryan Murray :
>gnustep-gui0's sound server is hanging the build daemons
>again, however :(
>
> When building gnustep-gui package or when building
>packages wich depend on gnustep-gui0 ?
>
> Which depend on gnustep-gui0. This can be caused by the
> sound daemon not
> properly backgrounding itself...
>
> What's the status on this? Recent gnustep needing uploads
> hung the buildds again. I'll be excluding these packages
> from the buildds if it isn't fixed the next time it
> happens...
Report from James Troup :
> gnustep_sndd doesn't properly daemonize (fails to close
> fds, I guess?)... Someone should beat "how to program a
> daemon" into gnustep upstream; this isn't the first (or
> second, or third :p) time we've had this problem with
> gnustep daemons.
>
> --
> James
Mattias Klose has written a patch wich fix the problem.
See the attached file.
|