bin/5296

KAREN THODE thode12 at msn.com
Thu May 22 05:10:14 PDT 2003


The following reply was made to PR bin/5296; it has been noted by GNATS.

From: "KAREN THODE" <thode12 at msn.com>
To: <freebsd-gnats-submit at freebsd.org>
Cc:  
Subject: bin/5296
Date: Thu, 22 May 2003 07:05:43 -0500

 ------=_NextPart_001_0000_01C32030.8F63FE80
 Content-Type: text/plain; charset="iso-8859-1"
 
 Here is another way to create the pidfile (or any file, for that matter):
 
 int create(char *path)
 {
      int fd;
      
      if((fd=open(path, CREATE|EXCL|WRONLY, READ|WRITE)) == -1)
      {
           return(0);
      }
      close(fd);
      return(1);
 }
 
 Note that create() returns a 1 on success and a 0 on failure.
 
 Lucas
 ------=_NextPart_001_0000_01C32030.8F63FE80
 Content-Type: text/html; charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 <HTML><BODY STYLE=3D"font:10pt verdana; border:none;"><DIV>Here is anothe=
 r way to create the pidfile (or any file, for that matter):</DIV> <DIV>&n=
 bsp;</DIV> <DIV>int&nbsp;create(char *path)</DIV> <DIV>{</DIV> <DIV>&nbsp=
 ;&nbsp;&nbsp;&nbsp; int fd;</DIV> <DIV>&nbsp;&nbsp;&nbsp;&nbsp; </DIV> <D=
 IV>&nbsp;&nbsp;&nbsp;&nbsp; if((fd=3Dopen(path, CREATE|EXCL|WRONLY, READ|=
 WRITE)) =3D=3D -1)</DIV> <DIV>&nbsp;&nbsp;&nbsp;&nbsp; {</DIV> <DIV>&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(0);</DIV> <DIV>&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</DIV> <DIV>&nbsp;&nbsp;&nbsp;&nbsp; close(=
 fd);</DIV> <DIV>&nbsp;&nbsp;&nbsp;&nbsp; return(1);</DIV> <DIV>}</DIV> <D=
 IV>&nbsp;</DIV> <DIV>Note that create() returns a 1 on success and a 0 on=
  failure.</DIV> <DIV>&nbsp;</DIV> <DIV>Lucas<BR><BR></DIV></BODY></HTML>
 
 ------=_NextPart_001_0000_01C32030.8F63FE80--


More information about the freebsd-bugs mailing list