1998Q2/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: Technical C/C++ coding question -->
<!--X-From-R13: Yngevan [pQyryna <xvgxngNgur486.oenqyrl.rqh> -->
<!--X-Date: Tue, 16 Jun 1998 17:34:58 &#45;0700 -->
<!--X-Message-Id: Pine.LNX.3.93.980616180310.10713A&#45;100000#the486,bradley.edu -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 19980616164557.01201#divcom,slimy.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: Technical C/C++ coding question</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:kitkat#the486,bradley.edu">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg01088.html">Previous</a>
&nbsp;|&nbsp;<a href="msg01090.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg01088.html">Previous</a>
&nbsp;|&nbsp;<a href="msg01091.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#01089">Author</A>
&nbsp;|&nbsp;<A HREF="#01089">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#01089">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: Technical C/C++ coding question</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] Re: Technical C/C++ coding question</LI>
<LI><em>From</em>: Katrina McClelan &lt;<A HREF="mailto:kitkat#the486,bradley.edu">kitkat#the486,bradley.edu</A>&gt;</LI>
<LI><em>Date</em>: Tue, 16 Jun 1998 18:20:53 -0500 (CDT)</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>


On Tue, 16 Jun 1998, Jon Leonard wrote:
&gt; On Sun, Jun 14, 1998 at 07:57:38AM -0700, J C Lawrence wrote:
&gt; &gt; Katrina McClelan&lt;kitkat#the486,bradley.edu&gt; wrote:
&gt; &gt; 
&gt; &gt; &gt; 	if(!fork()) { /* child copy starts here */
&gt; &gt; &gt;         kill(getpid(),SIGSEGV); /* this'll dump core */ 
&gt; &gt; &gt;         sleep(10); /* make sure it stops here */ 
&gt; &gt; &gt;         /* dead by here */ 
&gt; &gt; &gt;       }
&gt; &gt; &gt; 	/* parent continues unaware */
&gt; &gt; 
&gt; If I read the code right, the sleep is in the child, to keep the child
&gt; from executing additional parent code.  I'd include an exit() after the
&gt; sleep, so that if the kill doesn't work (SIGSEGV blocked?), the child
&gt; doesn't do any damage.
&gt; 

This is probably good.... the code I submitted was not meant (in my mind) 
to be fail safe.  The exit makes sure the child does no damage and is thus
good.  It's not really elegant, but then how elegant can you be when
you're trying to dump core ;)?  I assume this is only a tool and not going
to be a part of the finished server?  Even if it is, Ben can figure out
how to make it "perfect" from there.  SIGSEGV can be blocked, but
shouldn't be.  Actually I think the sleep is unneeded since the child
kills itself which is executed linear, so kill won't return until the
signal is sent and received thus killing the process in kill().  The exit
should be used incase kill fails. 

&gt; That said, I'd use abort() instead of kill, and not bother with the sleep.
&gt; I'd keep the exit() because I'm paranoid, and some older OSes may return
&gt; from abort.  If the appropriate signal is precise, the sleep is useless
&gt; anyway.
&gt; 

This is a better way to go, since abort can't return accd to the man page.

&gt; Failure to fork would be good to test for.  If you're willing to accept
&gt; a failure mode of no core file, the above code is find.  

I was assuming Ben was looking for just a quick and easy way and that he'd
add his own error checking.

&gt; I don't see any particular reason to do this.  It seems cleaner to me
&gt; to have the parent do nothing but the fork.
&gt; 

agreed.  The parent should IMO not get bogged down with this.
Particularly since there is an abort() command that I had never actually
used.  Learn something new every day  :)

-Kat



</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="01091" HREF="msg01091.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>
<ul compact><li><em>From:</em> Jon Leonard &lt;jleonard#divcom,slimy.com&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="01088" HREF="msg01088.html">[MUD-Dev] Re: Technical C/C++ coding question</A></STRONG>
<UL><LI><EM>From:</EM> Jon Leonard &lt;jleonard#divcom,slimy.com&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg01088.html">[MUD-Dev] Re: Technical C/C++ coding question</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg01090.html">[MUD-Dev] Re: Levelless MUDs</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg01088.html">[MUD-Dev] Re: Technical C/C++ coding question</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg01091.html">[MUD-Dev] Re: Technical C/C++ coding question</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#01089"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#01089"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Technical C/C++ coding question</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="01021" HREF="msg01021.html">[MUD-Dev] Technical C/C++ coding question</A></strong>, 
Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Sun 14 Jun 1998, 05:45 GMT
<UL>
<LI><strong><A NAME="01023" HREF="msg01023.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Katrina McClelan <a href="mailto:kitkat#the486,bradley.edu">kitkat#the486,bradley.edu</a>, Sun 14 Jun 1998, 06:52 GMT
<UL>
<LI><strong><A NAME="01034" HREF="msg01034.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sun 14 Jun 1998, 14:57 GMT
<UL>
<LI><strong><A NAME="01088" HREF="msg01088.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Jon Leonard <a href="mailto:jleonard#divcom,slimy.com">jleonard#divcom,slimy.com</a>, Tue 16 Jun 1998, 23:52 GMT
<UL>
<LI><strong><A NAME="01089" HREF="msg01089.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Katrina McClelan <a href="mailto:kitkat#the486,bradley.edu">kitkat#the486,bradley.edu</a>, Wed 17 Jun 1998, 00:34 GMT
<UL>
<LI><strong><A NAME="01091" HREF="msg01091.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Jon Leonard <a href="mailto:jleonard#divcom,slimy.com">jleonard#divcom,slimy.com</a>, Wed 17 Jun 1998, 01:36 GMT
<UL>
<LI><strong><A NAME="01092" HREF="msg01092.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Katrina McClelan <a href="mailto:kitkat#the486,bradley.edu">kitkat#the486,bradley.edu</a>, Wed 17 Jun 1998, 01:50 GMT
</LI>
<LI><strong><A NAME="01095" HREF="msg01095.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Wed 17 Jun 1998, 03:00 GMT
</LI>
<LI><strong><A NAME="01108" HREF="msg01108.html">[MUD-Dev] Re: Technical C/C++ coding question</A></strong>, 
Shawn Halpenny <a href="mailto:malachai#iname,com">malachai#iname,com</a>, Wed 17 Jun 1998, 15:41 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</ul>
</ul>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>