[PD-dev] PD bails, thread continues happily?

Mathieu Bouchard matju at artengine.ca
Sun Apr 5 01:30:43 CEST 2009

On Sat, 28 Mar 2009, B. Bogart wrote:

> I did a test today running a over 10,000 image captures using the
> "captureimages" method of [gphoto]. Everything seems to work, but the PD
> counter (based on bangs sent from the second thread) stopped at 2,000
> and PD became largely unresponsive.

I don't know what your problem is, but i found a few things: you are not 
checking whether the open() works, so, you rely on the next function to do 
it for you, which means that you lose the error message given by 
strerror(errno). And then when there's an error after that, you don't 
close(fd) by yourself, even though you do it when everything does work.

Note that you can't have more than about 1000 active fds at a time with 
Linux (it may be distro-dependent). Check what's the current limit on your 
system (2000?) using "ulimit -n" and then set that to a lower value like 
"ulimit -n 300" and try again, to see whether it has anything to do with 
filehandles. if it does, it's probably not because of one of the two bugs 
above, if I can suppose that the 2000 tries reported above do not end with 
an error.

Find the process ID of the second thread. let's say it's 12345. then do 
"ls -l /proc/12345/fd" to list all open-files of that process, and see if 
there is anything abnormal. If you have many "second threads" then... 
you'd need to look for each of them, I guess. Or are the fds shared among 
all threads?

> I was able to stop the thread with the PD method, so PD was not totally 
> dead, but I was unable to send any additional commands to the camera, 
> nor open another patch, or anything useful.

This sounds even more like "too many open files". Did that message appear 
in the console? It would also imply that the filehandle table is shared.

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec

More information about the Pd-dev mailing list