Segmentation fault(LINUX) and no idea why!

Thomas Wouters thomas at xs4all.net
Thu Jul 6 16:37:56 EDT 2000


On Thu, Jul 06, 2000 at 07:25:19PM +0000, Eric Lee Green wrote:
> Thomas Thiele wrote: 
> > In my program I create a new thread. In this new thread I fork and
> > replace the child with an other program
> > using excel. Normaly I have up to four threads with this procedure. So I
> > have a number of threads and the same numbers of childs (the called
> > program)
> > 
> > The problem is sometimes (relativly seldom, so it's unreproducible ;-( )
> > I get a segmantation fault and the pytthon interpreter stops.

> I haven't had good luck with forking a multi-threaded Python program, unless I
> immediately follow the fork() with an exec(). I suspect it's something to do
> with the internal state that Python uses as part of the thread stuff, but
> haven't cared enough to track it down (I dumped the whole 'threads' stuff
> instead, because I have found no way of telling whether a thread is still
> running or not...). 

If you do the fork() inside a C program (as opposed to os.fork() from a
python script), you have to call PyOS_AfterFork(). This was previously
undocumented, and the chief documenter didn't even know it existed ! :)

Unsure if this is the problem, though, I don't do anything with threads.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list