* Perl and File Locking
@ 2013-09-25 8:44 wynfield
2013-09-25 14:39 ` Warren Young
0 siblings, 1 reply; 3+ messages in thread
From: wynfield @ 2013-09-25 8:44 UTC (permalink / raw)
To: cygwin
Re: Perl 5, version 14, subversion 2 (v5.14.2)
Cygwin: CYGWIN_NT-5.1 1.7.25(0.270/5/3
In Perl (I am attempting to open a file and put an exclusive lock on it to update
it like this:
###########################################
use Fcntl qw( O_RDWR O_CREAT O_NONBLOCK O_EXLOCK );
sysopen($FH, $fname, O_RDWR | O_CREAT | O_NONBLOCK | O_EXLOCK, 0664)
############################################
Result on a test run give me the following error message:
"Your vendor has not defined Fcntl macro O_EXLOCK,"
Is it possible to develope perl code on cygwin that can use file locking to update data in a file from within perl?
Thank you.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Perl and File Locking
2013-09-25 8:44 Perl and File Locking wynfield
@ 2013-09-25 14:39 ` Warren Young
2013-10-15 14:15 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Warren Young @ 2013-09-25 14:39 UTC (permalink / raw)
To: Cygwin-L
On 9/25/2013 02:24, wynfield@gmail.com wrote:
>
> "Your vendor has not defined Fcntl macro O_EXLOCK,"
O_EXLOCK is a BSD feature, and Cygwin tries to emulate Linux, not BSD.
Minimal testing tells me you can use Cygwin's nonstandard
F_LCK_MANDATORY feature from Perl. This script, foo.pl, doesn't die:
#!/usr/bin/perl
sysopen my $fh, "foo.pl", 0600, O_RDONLY or die "sysopen: $!\n";
fcntl $fh, 0x99, 1 or die "fcntl: $!\n";
Whether it actually does what you expect is a different question.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Perl and File Locking
2013-09-25 14:39 ` Warren Young
@ 2013-10-15 14:15 ` Corinna Vinschen
0 siblings, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2013-10-15 14:15 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]
On Sep 25 08:25, Warren Young wrote:
> On 9/25/2013 02:24, wynfield@gmail.com wrote:
> >
> >"Your vendor has not defined Fcntl macro O_EXLOCK,"
>
> O_EXLOCK is a BSD feature, and Cygwin tries to emulate Linux, not BSD.
>
> Minimal testing tells me you can use Cygwin's nonstandard
> F_LCK_MANDATORY feature from Perl. This script, foo.pl, doesn't
> die:
>
> #!/usr/bin/perl
> sysopen my $fh, "foo.pl", 0600, O_RDONLY or die "sysopen: $!\n";
> fcntl $fh, 0x99, 1 or die "fcntl: $!\n";
>
> Whether it actually does what you expect is a different question.
Uh, no, don't do that. O_EXLOCK in the BSD world does *not* mean that
you want mandatory locking. It only means that the application wants an
exclusive lock on the entire file right at open time, thus allowing an
atomic open/lock under BSD flock semantics.
What you want to do is to call
sysopen my $fh, "foo.pl", 0600, O_RDONLY ...
[insert perl equivalent of the flock system call here]
That's not atomic, but this isn't provided (yet) utside the BSD world.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-15 14:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-25 8:44 Perl and File Locking wynfield
2013-09-25 14:39 ` Warren Young
2013-10-15 14:15 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).