Exclusive open of a file

I’m trying to open a file in an exclusive way with C.
But I couldn’t get it right.
Does anybody know how it works?

Thanks in advance.

Emiliano

Emi a écrit :

I’m trying to open a file in an exclusive way with C.
But I couldn’t get it right.
Does anybody know how it works?

Thanks in advance.

Emiliano

Did you try the lock() function (unistd.h)

Regards,
Alain.

If you are thinking of exclusive in the sense that DOS uses the word,
keep in mind that the Unix lock() function is advisory only, that is,
all applications trying to access the file must test and respect the
lock.

Alain Bonnefoy wrote:

Emi a écrit :

I’m trying to open a file in an exclusive way with C.
But I couldn’t get it right.
Does anybody know how it works?

Thanks in advance.

Emiliano

Did you try the lock() function (unistd.h)

Regards,
Alain.

Emi <emi@sortearsa.com.ar> wrote:
: I’m trying to open a file in an exclusive way with C.
: But I couldn’t get it right. Does anybody know how it works?

sopen() with a SH_DENY* mode.

Thank for your help, but I forgot to mention that I’m trying to open a
serial device, and sopen() function works ok with regular files but it
doesn’t with /dev/ devices.



“John Garvey” <jgarvey@qnx.com> escribió en el mensaje
news:9gagef$9ob$2@nntp.qnx.com

Emi <> emi@sortearsa.com.ar> > wrote:
: I’m trying to open a file in an exclusive way with C.
: But I couldn’t get it right. Does anybody know how it works?

sopen() with a SH_DENY* mode.