Package: nacl-tools
Version: 20110221-4.1
Severity: normal
Dear Maintainer,
I would like to report problem with curvecpmessage.
Curvecpmessage program (serverside) does not correctly collect zombies when
child process died.
How to reproduce:
1.run server side
../curvecpserver -v this.machine.name serverkey 127.0.0.1 10000
31415926535897932384626433832795 ./curvecpmessage sh -c 'timeout 10 cat
/dev/zero'
2.run client side:
timeout 1 ./curvecpclient this.machine.name `cat serverkey.hex` 127.0.0.1 10000
31415926535897932384626433832795 ./curvecpmessage -c sh -c 'exit 111'
You can run client again and again, and after 10 seconds You will see 'sh'
zombies.
I'm using workaround to fix the problem:
diff -Nur nacl-20110221.orig/curvecp/curvecpmessage.c
nacl-20110221/curvecp/curvecpmessage.c
--- nacl-20110221.orig/curvecp/curvecpmessage.c 2011-02-21 02:49:34.000000000
+0100
+++ nacl-20110221/curvecp/curvecpmessage.c 2011-10-31 12:52:10.727215587
+0100
@@ -135,6 +135,9 @@
long long lastpanic = 0;
+int childdied = 0;
+int pollret;
+
void earliestblocktime_compute(void) /* XXX: use priority queue */
{
long long i;
@@ -304,7 +307,10 @@
else
timeout = (nextaction - recent) / 1000000 + 1;
- if (poll(p,q - p,timeout) < 0) {
+ /* XXX */
+ if (childdied) timeout = 10;
+ pollret = poll(p,q - p,timeout);
+ if (pollret < 0) {
watch8 = 0;
watchtochild = 0;
watchfromchild = 0;
@@ -314,6 +320,11 @@
if (watchfromchild) if (!watchfromchild->revents) watchfromchild = 0;
}
+ /* XXX */
+ if (childdied && !pollret) {
+ if (childdied++ > 999) goto finish;
+ }
+
/* XXX: keepalives */
do { /* try receiving data from child: */
@@ -642,12 +653,23 @@
tochild[1] = -1;
} while(0);
+ /* XXX */
+ if (!childdied){
+ if (waitpid(child,&childstatus, WNOHANG) > 0) {
+ close(tochild[1]);
+ tochild[1] = -1;
+ childdied = 1;
+ }
+ }
}
+ if (!childdied) {
+ do {
+ r = waitpid(child,&childstatus,0);
+ } while (r == -1 && errno == EINTR);
+ }
- do {
- r = waitpid(child,&childstatus,0);
- } while (r == -1 && errno == EINTR);
+finish:
if (!WIFEXITED(childstatus)) { errno = 0; die_fatal("process killed by
signal",0,0); }
return WEXITSTATUS(childstatus);
-- System Information:
Debian Release: 8.3
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages nacl-tools depends on:
ii libc6 2.19-18+deb8u3
nacl-tools recommends no packages.
nacl-tools suggests no packages.
-- no debconf information