fuser

I am writing an application that uses two serial ports on a PC. I can run the application with no problems on ser1 but the same application blocks on ser2. I verified that the serial port settings are exactly the same.

Does the QNX operating has an equivalant to UNIX fuser to identify processes using files or sockets especially serial ports?

Thank You

“sin fd” ?
qnx.com/developers/docs/mome … s/sin.html

Here’s a quick hack that allows you to do this stuff programmably.

Pete

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>

#define MAX_LINE_LENGTH 200 /* arbitary limit */
static char buffer[ MAX_LINE_LENGTH ];

int main( int argc, char** argv )
{
int i;
int c;
FILE* f; /* popen() returns this /
/
Execute a command, creating a pipe to it for reading /
/
the output of the command into this process. /
if( ( f = popen(“sin fd | grep /dev/ser1” , “r” ) ) == NULL ) {
perror( “popen” );
return EXIT_FAILURE;
}
/
Let’s look at what the command has sent to the pipe /
if ( fgets( buffer, MAX_LINE_LENGTH, f ) == NULL )
/
no output from the command /
fprintf( stderr, “\nNo open port /dev/ser1\n”);
else {
/
Read and display all the output lines from the command. /
/
The device could be already opened from several processes */
fputs( buffer, stdout );
while ( fgets( buffer, MAX_LINE_LENGTH, f ) != NULL) {
fputs( buffer, stdout );
}
}
pclose( f );
return EXIT_SUCCESS;
}