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 != NULL)
       {
           tf_stat = fopen(tf_stat_file, "r");
           if (tf_stat != NULL)
           {
               /* Get state */
               stat_state=fgetc(tf_stat);

               /* Torrentflux asked to shutdown the torrent */
               if (stat_state == '0')
               {
                   mustDie = 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.

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to