Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ Programming
➜ General
➜ fork'ing abort()
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| halkeye
Canada (28 posts) Bio
|
| Date
| Wed 24 Dec 2003 12:32 AM (UTC) Amended on Wed 24 Dec 2003 12:38 AM (UTC) by halkeye
|
| Message
| Been wondering about fork and abort.
if i fork a process, can i abort and dump a core of the parent?
I'm trying to do crash/segviolation handling, while that is farily easy with the copyover/hotboot code, but i would like to have any crashes dump a core file too.
I figure if i do:
if (fork())
{
abort();
} else {
// code
}
Or will that kill both things?
|
Gavin
Dark Warriors - Coder
http://darkwars.wolfpaw.net
telnet://darkwars.wolfpaw.net:4848 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Wed 24 Dec 2003 03:11 AM (UTC) |
| Message
| | Once you have forked you have two copies of the process. It is fine to abort one of them. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Wed 24 Dec 2003 03:14 AM (UTC) |
| Message
| Anyway, write a 11-line test program and see for yourself ...
int main (void)
{
if (fork())
{
printf ("This process is aborting...\n");
abort();
}
else
{
printf ("This process is still working...\n");
}
return 0;
} // end of main
You probably need a couple of include files, but that is the general idea. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| halkeye
Canada (28 posts) Bio
|
| Date
| Reply #3 on Wed 24 Dec 2003 04:35 AM (UTC) Amended on Wed 24 Dec 2003 04:36 AM (UTC) by halkeye
|
| Message
| While i should have thought to actually try it, it just slipped my mind.
After reading many man pages on signals and fork and such, i thought i remebered being told that a child process will not handle singals.
I know there has to be a way, as daemons use fork(), but still handle singals.
Here is the code i'm currently trying, though it doesn't work.
/* signal( SIGPIPE, SIG_DFL );
signal( SIGSEGV, SIG_DFL );
signal( SIGTERM, SIG_DFL ); */
if (fork())
{
abort();
}
else
{
signal( SIGPIPE, SIG_IGN );
signal( SIGSEGV, SegVio );
signal( SIGTERM, SigTerm );
/* hotboot - Do Recovery Here */
}
I'm sure i'm missing something blatently obvious...
I think it has todo with the fact that the parent no longer exists. |
Gavin
Dark Warriors - Coder
http://darkwars.wolfpaw.net
telnet://darkwars.wolfpaw.net:4848 | | Top |
|
| Posted by
| halkeye
Canada (28 posts) Bio
|
| Date
| Reply #4 on Wed 24 Dec 2003 05:50 AM (UTC) |
| Message
| dude, i'm dumb. It works, just i'm unable to send kill signals to it.
at least it appears to work.
|
Gavin
Dark Warriors - Coder
http://darkwars.wolfpaw.net
telnet://darkwars.wolfpaw.net:4848 | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
19,022 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top