🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.comp.lang.perl
Article #16

Re: C open function in perl (lockfile)

#16
From: Tom Christiansen
Date: Fri, 03 Nov 1995 00:00
34 lines
1817 bytes
 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    gthelen@engin.umich.edu (Greg Thelen) writes:
:In article <47asja$728@csnews.cs.colorado.edu> Tom Christiansen <tchrist@mox.perl.com> writes:
:
:> In comp.lang.perl.misc, 
:>     pvr@korfu.igd.fhg.de (Reiners Dirk) writes:
:> :Can I emulate/call the normal C open function in/from perl.
:> :I want to translate the following code to perl:
:> :
:> :st=open("foo",O_CREAT|O_EXCL,0777)
:> :
:> :for writing a lockfile function (some machines here don't support flock :-(
:> :
:> :I have already a solution like
:> :
:> :syscall(&SYS_open, "foo", O_CREAT|O_EXCL, 0777);
:> :
:
:Any reason not to use the following (assuming Perl5)?
:
:$fd = POSIX::open($file, O_CREAT|O_EXCL|O_WRONLY, 0644);

You'd have to add

    $fh = POSIX::new_from_fd($fd, ">");

--tom
-- 
Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com

	    Rounded, wounded, grieve and sieve,
	    Friend and fiend, alive and live.
Technical Details
Message-ID: <47e7en$p94@csnews.cs.colorado.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4786us$a0f@korfu.igd.fhg.de> <47asja$728@csnews.cs.colorado.edu> <h1oohuu7sve.fsf@rackham.engin.umich.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1043e7,5ddc5a1c50ff66cd
X-Google-Attributes: gid1043e7,public
X-Google-Thread: 1133f4,5ddc5a1c50ff66cd
X-Google-Attributes: gid1133f4,public
X-Google-Thread: fa0ae,5ddc5a1c50ff66cd
X-Google-Attributes: gidfa0ae,public
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: C open function in perl (lockfile)
Date: 1995/11/03
Message-ID: <47e7en$p94@csnews.cs.colorado.edu>
X-Deja-AN: 118553709
references: <4786us$a0f@korfu.igd.fhg.de> <47asja$728@csnews.cs.colorado.edu> <h1oohuu7sve.fsf@rackham.engin.umich.edu>
organization: Perl Consulting and Training
reply-to: tchrist@mox.perl.com (Tom Christiansen)
newsgroups: de.comp.lang.perl,fj.lang.perl,comp.lang.perl.misc
originator: tchrist@mox