Return-Path: william@bourbon.usc.edu
Delivery-Date: Tue Apr 17 11:00:53 2007
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on merlot.usc.edu
X-Spam-Level: 
X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,
	NO_REAL_NAME autolearn=ham version=3.1.3
Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75])
	by merlot.usc.edu (8.13.5/8.13.5) with ESMTP id l3HI0r6X029479
	for <cs551@merlot.usc.edu>; Tue, 17 Apr 2007 11:00:53 -0700
Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1])
	by bourbon.usc.edu (8.13.5/8.13.5) with ESMTP id l3HI0u6g032200
	for <cs551@merlot>; Tue, 17 Apr 2007 11:00:56 -0700
Message-Id: <200704171800.l3HI0u6g032200@bourbon.usc.edu>
To: cs551@merlot.usc.edu
Subject: Re: problem in fgets 
Date: Tue, 17 Apr 2007 11:00:56 -0700
From: william@bourbon.usc.edu

Hi,

I'm just forwarding an e-mail from a student.  This may explain
the previously mentioned bug.
--
Bill Cheng // bill.cheng@usc.edu <URL:http://merlot.usc.edu/william/usc/>



  -----Original Message-----
  Date: Mon, 16 Apr 2007 23:51:16 -0700
  To: william@bourbon.usc.edu
  Subject: RE: problem in fgets

  Hi Professor,
  
  I was facing a similar problem and found out that the reason was that at one
  part of the code, I was closing index 0. and that is stdin.
  
  :-)
  
  Just thought to share with you.
  
  Regards,
   
  
  > -----Original Message-----
  > From: william@bourbon.usc.edu [mailto:william@bourbon.usc.edu] 
  > Sent: Thursday, March 22, 2007 9:55 PM
  > To: cs551@merlot.usc.edu
  > Subject: Re: problem in fgets
  > 
  > Someone wrote:
  > 
  >   > we are trying to implement the command prompt using fgets by
  >   > calling it repeatedly from a seperate thread. But it looks like
  >   > that it doesnt wait for the user input and infinitely prints the
  >   > command prompt. Kindly suggest the solution to this problem. Is
  >   > this a problem related with Pthread implementation..
  > 
  > Hmm...  This sounds familiar.  I think I've heard it from 
  > previous semesters.  But they were all fixed; although I 
  > don't recalling anyone telling me what the fix was.
  > 
  > If fgets() doesn't work but fread() one byte at a time works, 
  > you can write your own fgets() using fread() one byte at a time.
  > --
  > Bill Cheng // bill.cheng@usc.edu 
  > <URL:http://merlot.usc.edu/william/usc/>
  > 
  > 
