Hi folks,
Could you explain such a case please?
I’ve got a piece of code for testing qnx_name_locate(). Here it is:
-----------------------8<---------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#define PNAME “swd/test”
pid_t pid;
int nameid;
int main ()
{
if ( nameid = qnx_name_attach( 0, PNAME ) == -1 )
{
fprintf( stderr, "cannot attach name %s: ", PNAME );
perror( NULL );
return( EXIT_FAILURE );
}
puts( “Name attached; strike a key…” );
getch();
if ( pid = qnx_name_locate( 0, PNAME, 0, NULL ) == -1 )
{
fprintf( stderr, "cannot locate name %s: ", PNAME );
perror( NULL );
return( EXIT_FAILURE );
}
printf( “located %s at PID %d\n”, PNAME, pid );
qnx_name_detach( 0, nameid );
return( EXIT_SUCCESS );
}
-----------------------8<---------------------------
It registers the name OK (I can see it via “sin na”), but then qnx_name_locate() returns PID 0 instead of the real PID, so that the program reports that it has “located swd/test at PID 0”.
What may be wrong? I’m using WCC 10.6B under QNX 4.25C.
Thanks,
- Nick