I want to determine if another process has a device opened from a C
program. Utilities stty and qtalk seem to manage this but I haven’t
found a library function to tell me. Any hints?
Try the following:
open the device
dfd = open(“/dev/ser1”, O_RDWR);
get the device information
dev_info(dfd, &info);
examine the open count
if (info.open_count > 1){
another process has device open
}
else{
only this process has device open
}
If you want to wait until the current process is the only one that has it
open, I think you have to
close(), then open() again between each test.
(Of course, add appropriate error handling, variable declarations, and
necessary header files)
Bob Harris In short, you may buy a servant or slave,
Bath, NH but you cannot buy a friend.
bob@microprograms.com (Thoreau: Wild Fruits)
“Dean Douthat” <ddouthat@faac.com> wrote in message
news:3A5DC26F.EA9B9407@faac.com…
I want to determine if another process has a device opened from a C
program. Utilities stty and qtalk seem to manage this but I haven’t
found a library function to tell me. Any hints?
Thanks Robert. I though I looked into dev_info but must have missed the
open_count member.
“Robert L. Harris” wrote:
Try the following:
open the device
dfd = open(“/dev/ser1”, O_RDWR);
get the device information
dev_info(dfd, &info);
examine the open count
if (info.open_count > 1){
another process has device open
}
else{
only this process has device open
}If you want to wait until the current process is the only one that has it
open, I think you have to
close(), then open() again between each test.(Of course, add appropriate error handling, variable declarations, and
necessary header files)
Bob Harris In short, you may buy a servant or slave,
Bath, NH but you cannot buy a friend.
bob@microprograms.com > (Thoreau: Wild Fruits)“Dean Douthat” <> ddouthat@faac.com> > wrote in message
news:> 3A5DC26F.EA9B9407@faac.com> …
I want to determine if another process has a device opened from a C
program. Utilities stty and qtalk seem to manage this but I haven’t
found a library function to tell me. Any hints?
Oh, I see, open_count is not documented in the man page, only in the header.
Steve, should open_count be added to the man page?
Dean Douthat wrote:
Thanks Robert. I though I looked into dev_info but must have missed the
open_count member.“Robert L. Harris” wrote:
Try the following:
open the device
dfd = open(“/dev/ser1”, O_RDWR);
get the device information
dev_info(dfd, &info);
examine the open count
if (info.open_count > 1){
another process has device open
}
else{
only this process has device open
}If you want to wait until the current process is the only one that has it
open, I think you have to
close(), then open() again between each test.(Of course, add appropriate error handling, variable declarations, and
necessary header files)
Bob Harris In short, you may buy a servant or slave,
Bath, NH but you cannot buy a friend.
bob@microprograms.com > (Thoreau: Wild Fruits)“Dean Douthat” <> ddouthat@faac.com> > wrote in message
news:> 3A5DC26F.EA9B9407@faac.com> …
I want to determine if another process has a device opened from a C
program. Utilities stty and qtalk seem to manage this but I haven’t
found a library function to tell me. Any hints?
Dean Douthat <ddouthat@faac.com> wrote:
: Oh, I see, open_count is not documented in the man page, only in the header.
: Steve, should open_count be added to the man page?
Were you writing to me? I’ll add it to my list. Thanks for the suggestion.
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems
Steve Reid wrote:
Dean Douthat <> ddouthat@faac.com> > wrote:
: Oh, I see, open_count is not documented in the man page, only in the header.
: Steve, should open_count be added to the man page?Were you writing to me? I’ll add it to my list. Thanks for the suggestion.
Yes, thanks Steve.
Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems