Date: Wed, 17 May 2006 15:12:49 -0400 From: "Andy Greenwood" <greenwood.andy@gmail.com> To: "Lorin Lund" <wbs@infowest.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: C coding question Message-ID: <3ee9ca710605171212h75e61ae0pab91f50d1559b082@mail.gmail.com> In-Reply-To: <446B6D38.4070105@infowest.com> References: <3ee9ca710605171109i57ae4064x702216a1619d6c41@mail.gmail.com> <446B6D38.4070105@infowest.com>
next in thread | previous in thread | raw e-mail | index | archive | help
That did it! thanks so much!
On 5/17/06, Lorin Lund <wbs@infowest.com> 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.
>
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3ee9ca710605171212h75e61ae0pab91f50d1559b082>
