From owner-freebsd-questions@FreeBSD.ORG Wed May 17 19:12:52 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BBA7016BB98 for ; Wed, 17 May 2006 19:12:52 +0000 (UTC) (envelope-from greenwood.andy@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1D2CC43D45 for ; Wed, 17 May 2006 19:12:51 +0000 (GMT) (envelope-from greenwood.andy@gmail.com) Received: by ug-out-1314.google.com with SMTP id m3so299074uge for ; Wed, 17 May 2006 12:12:49 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SApJzbQi4R0rN4SyssQ1+0WQbzEDFLcRPInMu+LpdTEm0E3tY8mrsPcywRYj7Q8u84syyYHIWFP6zEbPcGlfgUGODWoWvEFJN9QCF2Dw9ke+UIG+4S/C6Un5UYzcOJkwiu5OxNByZxke057FITrhYpeHNKUFEu6UmMd8vklhE/k= Received: by 10.67.111.26 with SMTP id o26mr876112ugm; Wed, 17 May 2006 12:12:49 -0700 (PDT) Received: by 10.66.251.9 with HTTP; Wed, 17 May 2006 12:12:49 -0700 (PDT) Message-ID: <3ee9ca710605171212h75e61ae0pab91f50d1559b082@mail.gmail.com> Date: Wed, 17 May 2006 15:12:49 -0400 From: "Andy Greenwood" To: "Lorin Lund" In-Reply-To: <446B6D38.4070105@infowest.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <3ee9ca710605171109i57ae4064x702216a1619d6c41@mail.gmail.com> <446B6D38.4070105@infowest.com> Cc: FreeBSD Questions Subject: Re: C coding question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 May 2006 19:12:59 -0000 That did it! thanks so much! On 5/17/06, Lorin Lund wrote: > Andy Greenwood wrote: > > > I am helping someone work on porting some code to Freebsd, and the > > code below works on Linux, but not on FreeBSD (compiles, but gives > > Segmentation Fault: 11). I'm not sure where the problem is, and any > > pointers would be much appreciated. > > > > /* Check if we must stop */ > > if(tf_stat_file !=3D NULL) > > { > > tf_stat =3D fopen(tf_stat_file, "r"); > > if (tf_stat !=3D NULL) > > { > > /* Get state */ > > stat_state=3Dfgetc(tf_stat); > > > > /* Torrentflux asked to shutdown the torrent */ > > if (stat_state =3D=3D '0') > > { > > mustDie =3D 1; > > } > > } > > fclose(tf_stat); > > } > > _______________________________________________ > > I think I would move the > fclose( tf_stat) > up a line. No need to close a file that failed to open. The fclose( ) > acting on > a NULL pointer might be your error. > >