HP-UX Reference (11i v2 07/12) - 2 System Calls (vol 5)

p
pstat(2) pstat(2)
pstat_getpsem()
,orpstat_getnode()
calls.
[EINVAL]
index is not a valid logical node id for pstat_getnode()
call.
[EINVAL]
elemcount is less than or equal to zero for pstat_getpathname()
call.
[EINVAL] If
pstat_getfiledetails()
is called for a socket other than AF_UNIX
family or
pstat_getpathname
is called for a socket.
[EINVAL] If
pstat_getsocket()
is called for a file which is not of type socket.
[EINVAL] If
pstat_getcommandline()
is called with pid less than zero or elem-
count
not equal to one .
[EACCES] If uid!=0 and effective id does not match for calls
pstat_getfiledetails()
, pstat_getsocket()
,
pstat_getstream()
, and pstat_getpathname()
.
[EOVERFLOW] Offset element is too large to store into the structure pointed to by the
buf
argument.
[EOVERFLOW] For the pstat_getfiledetails()
call, a value to be stored would
overflow one of the members of the
pst_filedetails
structure. The
psfd_valid member indicates the field that overflowed.
[EOVERFLOW] For the pstat_getpathname()
call, the elemcount parameter is not one
greater than the length of the pathname to be returned.
[ENOSTR]
pstat_getstream()
is called for a file which is neither a stream nor a
stream based pipe/socket.
[EINTR] For
pstat_getsocket()
call, the operation was terminated due to the
receipt of a signal, and no data was transferred.
[ENOBUFS] For
pstat_getsocket()
call, the operation was terminated due to unavaila-
bility of buffer space.
[ENOSYS] The requested pstat function is not implemented or not configured in the system.
BACKWARD COMPATIBILITY
The specific calling convention of passing the expected data structure size is used in order to allow for
future expansion of the interface, while preserving backwards source and object compatibility for programs
written using the pstat interfaces. Three rules are followed to allow existing applications to continue to
execute from release to release of the operating system.
New data for a context are added to the end of that context’s data structure.
Old, obsolete data members are
NOT deleted from the data structure.
The operating system honors the elemsize parameter of the call and only returns the first
elemsize bytes of the context data, even if the actual data structure has since been enlarged.
In this way, an application which passes its compile-time size of the context’s data structure (for example,
sizeof(struct pst_processor
) for the per-process context) as the elemsize parameter will
continue to execute on future operating system releases without recompilation, even those that have larger
context data structures. If the program is recompiled, it will also continue to execute on that and future
releases. Note that the reverse is not true: a program using the
pstat interfaces compiled on, say, HP-
UX release 10.0 will not work on HP-UX release 9.0.
The code examples, below, demonstrate the calling conventions described above.
EXAMPLES
#include <sys/param.h>
#include <sys/pstat.h>
#include <sys/unistd.h>
/*
* Example 1: get global information from pstat_getstatic()
*/
{
struct pst_static pst;
284 Hewlett-Packard Company 11 HP-UX 11i Version 2: December 2007 Update