Re: What's up with our stdout?



On Monday 26 June 2006 00:07, Andrew Reilly wrote:
On Sun, Jun 25, 2006 at 02:40:21PM -0700, John-Mark Gurney wrote:
Andrew Reilly wrote this message on Sun, Jun 25, 2006 at 11:17 +1000:
One interesting problem that I found yesterday was that NetBSD
have added a "-l" option to cat, which is supposed to apply an
exclusive advisory lock with fcntl to the the output file, and
wait until that succeeds:
http://netbsd.gw.com/cgi-bin/man-cgi?cat++NetBSD-current
That seems like a pretty useful idea,
because it means that you can have parallel make jobs all
contributing to a log file or the like (with cat -l >> foo.log),
without getting in eachothers' way.

Why not use:
lockf -k foo.log cat >> foo.log

Should do the same thing...

Not only should it, I've just checked and discovered that it
does. So I'll make up the appropriate tweak to NetBSD's
Makefiles, and suggest on the mailing lists that they think
about incorporating it, as it's ostensibly a more general and
useful way to do it.

This does make me wonder, though, why this _does_ work, given
Bruce's explanation of why the nbcat code doesn't...

Hmm. lockf.c uses open(...,|O_EXLOCK), rather than fcntl().
Any particular reason why that should behave differently?

I believe that's an 'flock()' rather than an 'fnctl()' range lock.

Are you doing your build over NFS btw?

--
John Baldwin
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Whats up with our stdout?
    ... exclusive advisory lock with fcntl to the the output file, ... contributing to a log file or the like (with cat -l>> foo.log), ... and suggest on the mailing lists that they think ...
    (freebsd-arch)
  • Re: Whats up with our stdout?
    ... exclusive advisory lock with fcntl to the the output file, ... contributing to a log file or the like (with cat -l>> foo.log), ...
    (freebsd-arch)
  • Re: Script help: convert music files to be compatible with MPD
    ... command will be written to it. ... I tried it with both> and>> and with the file both left and right of the escaped semicolon. ... It looks as if find redirects its own output file or pipe and then runs external commands with its outputs spliced onto its own output channels. ... cat /dev/null> $@ ...
    (uk.comp.os.linux)
  • Re: Corrupt a File with "cat" ?
    ... <cat> can definitely alter a file. ... the output file will be changed permanently. ... It's byte count can also be set to zero by the operation, ... the result will be that <file1> will then contain zero bytes. ...
    (alt.os.linux)
  • Re: Corrupt a File with "cat" ?
    ... <cat> can definitely alter a file. ... the output file will be changed permanently. ... It's byte count can also be set to zero by the operation, ... the result will be that <file1> will then contain zero bytes. ...
    (alt.os.linux.redhat)