home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!eng.ufl.edu!atlantis.cis.ufl.edu!bcs
- From: bcs@atlantis.cis.ufl.edu (Bradley C. Spatz)
- Subject: open and O_EXCL.
- Message-ID: <1992Jul31.192224.27505@eng.ufl.edu>
- Keywords: open flags mutex
- Sender: news@eng.ufl.edu (Usenet Diskhog System)
- Reply-To: bcs@atlantis.cis.ufl.edu (Bradley C. Spatz)
- Organization: UF Computer Science Dept.
- Date: Fri, 31 Jul 92 19:22:24 GMT
- Lines: 26
-
- Hi.
-
- How can I specify the flags (like O_EXCL) to open(2) with Perl's open?
-
- I want to open a file like vipw does with /etc/passwd, such that my Perl
- script and vipw will not be able to access the file simultaneously.
-
- The way vipw does this is by:
-
- fd = open("/etc/ptmp", O_WRONLY|O_CREAT|O_EXCL, 0644);
- if (fd <0) {
- complain(); exit(1)
- }
-
- If opened ok, then the fd is converted to a fp and /etc/passwd is copied to
- /etc/ptmp. The latter serves as a lock.
-
- I want to similarly enforce mutual exclusion on this file. However, Perl's
- open doesn't seem to allow the flags (O_WRONLY|O_CREAT|O_EXCL) to be specified. Can I specify these flags these flags in Perl?
-
- Any suggestions? I'll post a summary.
- --
- Bradley C. Spatz Bytes: bcs@ufl.edu
- Computer & Information Sciences Bits: uunet!uflorida!bcs
- College of Engineering Waves: 904/392-1499
- University of Florida "School IS hell." -- Matt Groening
-