Return-Path: william@bourbon.usc.edu Delivery-Date: Sun Oct 12 08:12:07 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m9CFC7bg021371 for ; Sun, 12 Oct 2008 08:12:07 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m9CFJMxZ013914 for ; Sun, 12 Oct 2008 08:19:22 -0700 Message-Id: <200810121519.m9CFJMxZ013914@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: CS 551 final 1 Date: Sun, 12 Oct 2008 08:19:22 -0700 From: Bill Cheng Someone wrote: > Its mentioned in the FAQ that: > > *" .........Please note that nodes X and Y will create a child thread each > to handle the other end of these connections. At the same time, node X will > terminate the 2nd child thread that's sleeping for 30 seconds and node Y > will terminate the child thread that's sleeping for 30 seconds*." > > My question is, can we terminate the sleeping threads with a SIGKILL or > should we handle it with SIGTERM ? You can use SIGTERM, SIGINT, or any signal to wake up this thread and have this thread checking a flag to see if it's time to terminate. > Basically, can we do a "forceful" termination ? You will never get an "yes" from me for something like this! :-) The way you *should* write code is to have only one exit point for any thread. I think this is the first thing you need to try to get good at. After you get really good at this, you can do it other ways. Pthread has functions that you can use to kill a thread. But you need to be very careful when to do it and how to clean up whatever a thread might left behind. -- Bill Cheng // bill.cheng@usc.edu