S
sunil
Hi All,
I am tring to debug the following program.I written this
program in HP-Unix and I am using the GDB as a debugger.
#include <stdio.h>
#include<unistd.h>
int main()
{
int pid;
pid = fork();
if(pid == 0)
{
printf("I am the child process,my processid is\t
%d\n",getpid());
printf("I am the child's parent process,my processid
is\t %d\n",getppid());
sleep(20);
printf("I am the child process,my processid is\t
%d\n",getpid());
printf("I am the child's parent process,my processid
is\t %d\n",getppid());
}
else
{
printf("I am the parent process,my processid is\t
%d\n",getpid());
printf("I am the parent's parent process,my processid
is\t %d\n",getppid());
}
}
While debugging using any debugger by default it will take only
parent process to debug.If u want to debug the child process we have to
use the "info threads" command and get the thread numbers.
And we have to switch to the child thread,this is what the
general procedure is.
But in my case it is showing only one entry after executing the
info threads command,I executed this command after the if loop.
Could anybody suggest how to trap that child thread and how to
debug that process.i put the break point at the if loop.If anybody
couldn't get it plz revert back to me.
Regards
Sunil
I am tring to debug the following program.I written this
program in HP-Unix and I am using the GDB as a debugger.
#include <stdio.h>
#include<unistd.h>
int main()
{
int pid;
pid = fork();
if(pid == 0)
{
printf("I am the child process,my processid is\t
%d\n",getpid());
printf("I am the child's parent process,my processid
is\t %d\n",getppid());
sleep(20);
printf("I am the child process,my processid is\t
%d\n",getpid());
printf("I am the child's parent process,my processid
is\t %d\n",getppid());
}
else
{
printf("I am the parent process,my processid is\t
%d\n",getpid());
printf("I am the parent's parent process,my processid
is\t %d\n",getppid());
}
}
While debugging using any debugger by default it will take only
parent process to debug.If u want to debug the child process we have to
use the "info threads" command and get the thread numbers.
And we have to switch to the child thread,this is what the
general procedure is.
But in my case it is showing only one entry after executing the
info threads command,I executed this command after the if loop.
Could anybody suggest how to trap that child thread and how to
debug that process.i put the break point at the if loop.If anybody
couldn't get it plz revert back to me.
Regards
Sunil