[PD-dev] Shell and long-term instability

B. Bogart ben at ekran.org
Fri Dec 21 02:23:05 CET 2007


Indeed lots of message on pd-list about [shell]

So what is the solution?

Me making a bunch of custom call externals for each purpose seems a bit
silly. Johannes's method of using a shell server sending commands over a
 pipe makes sense, but it would be nice to be able to do it from PD proper.

So what is the best solution? Fixing shell or some new external that
does a similar job?

Note my tests were using nogui so there would be no tk to "freeze" and I
was still getting some pretty bad instabilities.

What I was using shell for:

* executing "xset dpms force suspend" to put the displays to sleep
overnight.

Things went totally bad when I tried to get the OS CPU and Memory usage
using:

"ps -p `pgrep -o -x pd` h -o %cpu"

or %mem for memory usage.

Ideas?

.b.

Mathieu Bouchard wrote:
> On Mon, 26 Nov 2007, Hans-Christoph Steiner wrote:
> 
>> Yeah, [shell] definitely acts strangely sometimes.
> 
> [shell] uses system() instead of the commented-out execvp(). This
> requires the child to exit by itself. This is done using a call to
> exit(). exit() calls all exit handlers registered by atexit(), which
> includes some that are registered by gcc/glibc that call fclose() on all
> remaining filehandles. fclose() calls fflush() prior to destructing the
> filehandle. fflush() may contain duplicate data that is sent a second
> time completely out of sync with what the main process is sending
> through the same socket. It is the same socket because fork() copies all
> low-level filehandles (int fd) from one process to the other, with the
> exact same destination. Thus when the sys_gui() buffer is not empty
> during a fork(), an exit() will garble the tk command socket's data,
> which may happen in a way that an open brace is sticking in the air or
> whatever can freeze pd.tk, i don't know what it is in particular.
> 
> I believe that _exit() does not flush the filehandles. The manpage says
> it closes files, but they must mean only "int fd", whose buffers are
> shared between all owning processes, unlike "FILE *" buffers.
> 
>  _ _ __ ___ _____ ________ _____________ _____________________ ...
> | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev






More information about the Pd-dev mailing list