“Roger Parent @ Sigma inc.” <rparent@sigma-techno.com> wrote in message
news:96born$g0t$1@inn.qnx.com…
The qnx_psinfo need the pid, i don’t want give the pid, i want to give the
process name like i can do with sin -P pgmx.
You don’t provide the pid you start with a pid of 0 and start the scan from
there.
I don’t want to check all process to see if the of the process fit’s with
the name i got(pmgx).
There can’t be any black magic here, somebody has to scan the list
of process to see if one exists. In this case the OS/lib doesn’t
provide a function to do it for you, so you have to do it yourself.
Just turn the snippet of code I post into a function, put it
in a library and forget it’s “scanning” 
Do you know another method, like OS method.
Well this is an OS method.
If you want to to it the hard way you could do.
f = popen( “sin -P pgmx”);
read(f…);
close(f);
Then you can parse the data return by read().
“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le message
news: 96bjii$9mq$> 1@nntp.qnx.com> …
Sorry.
If your program attach a name (qnx_name_attach() ) or any other easy
to detect resource, just check if the resource already exits.
If not scan the list of running processes to check if a process with
the name ABCD is already running:
int id;
int count;
struct _psinfo data;
id = 0;
count = 0;
while( ( id = qnx_psinfo( 0, ++id, &data, 0, 0 ) ) != -1 ) {
if ( data.un.proc.name ) { // robustness
char *p;
p = strrchr( data.un.proc.name, ‘/’ ); // extract program name
if ( p ) {
if ( strstr( p, “program name” ) ) {
++count;
}
}
}
}
return count;
The following isn’t perfect because of the use of strstr.
If a program call abcdefg is running and your program is
called abcd, since abcd is a subset of abcdefg strstr will
succeed.
“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in message
news:96bego$9nv$> 1@inn.qnx.com> …
Ok, but how i can do this ?
“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le
message
news: 96begs$6tv$> 1@nntp.qnx.com> …
I wouldn’t to this from the script, I would rather let pgmx do its
own
checking.
“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in
message
news:96bcl6$8lj$> 1@inn.qnx.com> …
I want to make a script to execute a program pgmx, before this the
script
need to check if the pgmx is in memory (already running).
I have try with;
sin -h -P pgmx format i
and the sin don’t have a return code. If the program is running,
this
working but if it’s not the sin return;
sin: no process(es) found.
i try to catch it with this command;
RESULT=sin -h -P pgmx format i | cut -c1-5
and if the program is not running RESULT have a blank string on
it.
Do someone have done this in a script or by a Watcom command.
Thanks Roger.
–
Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: > rparent@sigma-techno.com
Web: > www.sigma-techno.com
\