[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] GTP sometimes fails

From: Paul Pogonyshev
Subject: Re: [gnugo-devel] GTP sometimes fails
Date: Sat, 19 Mar 2005 12:57:45 +0200
User-agent: KMail/1.4.3

Darren Cook wrote:
> > It is failing on set_random_seed, which is the first command after
> > getting the connection. Specifically it fails on my 3rd unit test -
> It worked (tested by doing my 3 tests 100 times) by adding a usleep(1);
> after my fwrite() command and before doing the fgets() call.
> I also now explicitly kill the child pid when I disconnect, but as far
> as I can tell that made no difference: ps still shows 300 [gnugo
> <defunct>] zombies, but they all disappear when my program closes.

I assume you use wait() or waitpid(), not kill() here, right?

Somehow, my `gtp-test' does neither, but I get no zombie processes

> I guess my usleep() is a kludge and the real problem is how I connect or
> disconnect. But as multiple connect/disconnects is probably only going
> to happen in my unit tests it is good enough.

Yes, it is.  That usleep() ``fixes'' things indicates that pipes are
asynchronous (non-blocking) and you should use select() function.
Apparently, I use it too in my `gtp-test'; wrote it long ago, so I
forgot about this.

Another possible solution might using fcntl() to make the pipe IO
blocking, but I don't know if this is possible.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]