Operating System - HP-UX
1824559 Members
3963 Online
109672 Solutions
New Discussion юеВ

Re: how to cause a process to dump core

 
SOLVED
Go to solution
Ken_109
Advisor

how to cause a process to dump core

In the C language, How can i programatically cause a process or an individual thread to dump core. Without causeing the process to terminate? I can use the abort system call. but this causes the process to stop. Any ideas? Thanks,Ken
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: how to cause a process to dump core

Here's one sneaky approach: fork() and have the child invoke abort().
If it ain't broke, I can fix that.
Ken_109
Advisor

Re: how to cause a process to dump core

Interesting approach, unfortunately probably not a doable thing, since this program is attached to other running processes ( Oracle ) and would continue executing. Possibly causing a deadlock or other problems. Unfortunately, this process can't have itself running simultaneously..
A. Clay Stephenson
Acclaimed Contributor

Re: how to cause a process to dump core

I suspect that
{
i = 1;
j = k;
...
if (fork() == 0) abort(); /* child instantly dies after VAS is copied */
/* parent continues just as though nothing had happenned 8/
i = 2;
j = k + 1;
...
}
will be quite safe.

Just make sure that you use fork() rather than vfork().
If it ain't broke, I can fix that.
Ken_109
Advisor

Re: how to cause a process to dump core

Ill look at that... The program is multi threaded so maybe. It might depend upon the scheduler. In otherwords if the thread that forks isn't the one that gets on the cpu when the fork system call returns....
Michael Schulte zur Sur
Honored Contributor

Re: how to cause a process to dump core

Hi,

what is the programme supposed to do after core dump? Sit there and wait? ;-)

What's wrong with ACS's first attempt?
The child dies, the other does, whatever you programme in the else routing.

greetings,

Michael
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: how to cause a process to dump core

I also recall a program called "gcore" mentioned in one of the sessions at HP World (2001 I think) that could induce a core dump in a running process and leave the puppy otherwise intact. You might look for it. I don't do them Web searches very often.
If it ain't broke, I can fix that.
Ken_109
Advisor

Re: how to cause a process to dump core

Nothings wrong with ACS approach. I don't want the process to pause. It should continue to run. In fact I'll attempt his suggestion. The only reservation I have is that since the fork() call and the call to abort are not atomic. This means that the other threads of execution could actually be scheduled on the CPU to run. This would be verry bad indeed :).... But I'll look into it. Thanks again to ACS and everone who's contributed!