[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: fork-exec causes core-dump

I wish to run it in a loop
so that I can do other things in the loop.

----- Original Message ----- 
From: Arun Sharma <adsharma@xxxxxxxxxxxxxxx>
To: <linux-india-programmers@xxxxxxxxxxxxxxxxxxxxx>
Sent: Sunday, October 08, 2000 2:11 AM
Subject: Re: [LIP] fork-exec causes core-dump

> From gdb.info:
> Debugging programs with multiple processes
> ==========================================
>    GDB has no special support for debugging programs which create
> additional processes using the `fork' function.  When a program forks,
> GDB will continue to debug the parent process and the child process
> will run unimpeded.  If you have set a breakpoint in any code which the
> child then executes, the child will get a `SIGTRAP' signal which
> (unless it catches the signal) will cause it to terminate.
>    However, if you want to debug the child process there is a workaround
> which isn't too painful.  Put a call to `sleep' in the code which the
> child process executes after the fork.  It may be useful to sleep only
> if a certain environment variable is set, or a certain file exists, so
> that the delay need not occur when you don't want to run GDB on the
> child.  While the child is sleeping, use the `ps' program to get its
> process ID.  Then tell GDB (a new invocation of GDB if you are also
> debugging the parent process) to attach to the child process (see *Note
> Attach::).  From that point on you can debug the child process just
> like any other process which you attached to.
> On Sat, Oct 07, 2000 at 04:14:37PM +0530, Delip Rao wrote:
> > Hi,
> >  I used fork-exec to create a child process, 
> > it ran properly but caused a core dump.
> >  
> > Since I wished to run it in the background I used,
> >    waitpid(pid,&status,WNOHANG|WUNTRACED);   inside a loop
> >  
> Why would you want to run it in a loop ?
> -Arun
> ---------------------------------------------
> LIP is all for free speech.  But it was created
> for a purpose.  Violations of the rules of
> this list will result in stern action.