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