LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CheckForDuplicateAppInstance in Posix ?

Hello all,

I often use CheckForDuplicateAppInstance() from my CVI programs, but I need
to do the same things under Linux in a non-CVI program. Anyone knows the
equivalent Posix call ?

Thanks.
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 2
(2,862 Views)
I got an answer in a different forum (thanks Rainer). It's done mostly by
locking a resource like that:

struct flock lock;
int fd, rc;

fd = open("/path/to/FileOrDevice", O_RDWR);

lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = lock.l_len = 0;
rc = fcntl(fd, F_SETLK, &lock);

If the file is unlocked, rc will be 0 and the process will have
acquired an exlusive lock on it. Otherwise, rc will be -1 and errno
contain a 'suitable error code' (either EAGAIN or EACCESS).

Anyway, it's a bit offtopic here.

--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 2 of 2
(2,825 Views)