ask for some functions

hello,everybody

I am trying to do some programming practices with QNX6.1,can anybody
introduce some functions to me?

1,first,I am thinking are there some functions which can let me know the
state and informations of another process running in a remote node? that
is,its pid,whether it is blocked,active or died?(the process’ name is
known).

2,there is a global variable named errno ,and a utility of the same name
which can expain the errno to string,I am thinking is there a function which
can take the number of errno as its input parameter and the output will be
the error string?or how can I redirect the output of the utility errno to a
string varible in my application?

3,in phab I create a application,I try to output a string to a terminal,so,I
fd=open("/dev/ptyp1",…) and write the string to the fd,but nothing
happened,why open can not open a pterm for me?and,if I spawnlp(pterm) myself
before the open operation,the pterm was loaded,but still the string can not
be wreted to it,y?

“ChaoLi” <QNX_NEW@SOHU.COM> wrote in news:a7vckv$9jm$1@inn.qnx.com:

hello,everybody

I am trying to do some programming practices with QNX6.1,can anybody
introduce some functions to me?

1,first,I am thinking are there some functions which can let me know
the state and informations of another process running in a remote node?
that is,its pid,whether it is blocked,active or died?(the process’ name
is known).

You can use qnet, and check the /net//proc/ and scan through the
pids, doing a devctl() to extract the name. Take a look at pidin on the
public CVS (cvs.qnx.com) for an example.

2,there is a global variable named errno ,and a utility of the same
name which can expain the errno to string,I am thinking is there a
function which can take the number of errno as its input parameter and
the output will be the error string?or how can I redirect the output of
the utility errno to a string varible in my application?

the C function is called strerror() - you should look into getting a good C
book. K&R’s book is about the best that I could recommend.

3,in phab I create a application,I try to output a string to a
terminal,so,I fd=open("/dev/ptyp1",…) and write the string to the
fd,but nothing happened,why open can not open a pterm for me?and,if I
spawnlp(pterm) myself before the open operation,the pterm was
loaded,but still the string can not be wreted to it,y?

When you spawn’ed the pterm, how did you know which pty it was attached to?
You can do a simple experiment - just open a pterm, and do:

echo “some string” > /dev/ptyp[x]

Where [x] is the number of the pty that is attached to that pterm (look at
the title bar). Echo does a simple Open, write, close… so it should be
possible.

\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Adam Mallory <amallory@qnx.com> wrote:
: the C function is called strerror() - you should look into getting a good C
: book. K&R’s book is about the best that I could recommend.

It’s also described in the QNX C Library Reference. The docs for errno
even include an example that uses it.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Dear Adam and steve,thanks for your helps you gave me yesterday,but I still
want to discuss my questions for a little further.
As we know,the message passing is the most hornor thing of QNX,but as I
checked,every message passing functions of qnx shall have the pid (message
sending or message receiving) as their parameter.Just consider this
situation:in a qnet network,there is a database server running and in the
same time,there are some clients running in other nodes,the client
applications shall ask the database server for data services and they can
start and quit randomly,so,the clients have to send the data requests to the
server by sending the server a message,that means they client shall have to
know the server id at first,how the client do that?ok,I know that when the
qnet is working ,there shall have a directory of /net//pids…,I can scan this drirectory and check the pids one by one to
find out which pid is the server’s,is that the one way I can take?if yes,how
can I do the checking?(I have to read the source code of pidin first?)
I find some other functions that are name_attach,name_open,name_close which
can so do part of my job,as in the case discribed above,when the server
start,it run the name_attach and register itself globally,also the client
can name_open it then get a channel id,so the server application services as
a resource manager,the question are:is there a function that can check
whether a specific name existing? if there is not,can I use the “open”
function and do the checking by the return value of “open”?
thanks .
best regards.
ChaoLi

ChaoLi <QNX_NEW@sohu.com> wrote:

Dear Adam and steve,thanks for your helps you gave me yesterday,but I still
want to discuss my questions for a little further.
As we know,the message passing is the most hornor thing of QNX,but as I
checked,every message passing functions of qnx shall have the pid (message
sending or message receiving) as their parameter.Just consider this
situation:in a qnet network,there is a database server running and in the
same time,there are some clients running in other nodes,the client
applications shall ask the database server for data services and they can
start and quit randomly,so,the clients have to send the data requests to the
server by sending the server a message,that means they client shall have to
know the server id at first,how the client do that?ok,I know that when the
qnet is working ,there shall have a directory of /net//pids…,I can scan this drirectory and check the pids one by one to
find out which pid is the server’s,is that the one way I can take?if yes,how
can I do the checking?(I have to read the source code of pidin first?)

You can also have the server write “nd/pid/chid” into a “well known file”
(like /var/run/dbserver), and client open that file to get the server
information.

However, this is not the recommanded way.

I find some other functions that are name_attach,name_open,name_close which
can so do part of my job,as in the case discribed above,when the server
start,it run the name_attach and register itself globally,also the client
can name_open it then get a channel id,so the server application services as
a resource manager,the question are:is there a function that can check
whether a specific name existing? if there is not,can I use the “open”
function and do the checking by the return value of “open”?

name_open() return an fd, which is a “connection id”, so you could
MsgSend() through it.

the resource manager gives you a posix layer cover, so you could
open()/read()/write()/close() the path name created by resmgr_attach().

-xtang