Return-Path: william@bourbon.usc.edu Delivery-Date: Wed Oct 15 11:28:40 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 m9FISeaW005880 for ; Wed, 15 Oct 2008 11:28:40 -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 m9FIaeYo004561 for ; Wed, 15 Oct 2008 11:36:40 -0700 Message-Id: <200810151836.m9FIaeYo004561@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: cs 551 - regarding signal? Date: Wed, 15 Oct 2008 11:36:40 -0700 From: Bill Cheng Someone wrote: > a basic question. in the following codes, if thread is sleeping and got a > SIGINT or SIGUSR, it will do interrupt routine and what next will go? > should go back to sleep, if it still has 10 secs not ready to finish. > or should go to code 2? > > while (true) > { > // code 1 > sleep(30); > // code 2 > } > thanks in advanced It will go back to sleep. That's why you should use select() to sleep instead of using sleep() to sleep! -- Bill Cheng // bill.cheng@usc.edu