Would someone post or mail me some code to fetch the prpsinfo
structure defined in man proc. My attempt feteched me a device busy.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/file.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/fault.h>
#include <sys/syscall.h>
#include <sys/procfs.h>
#include <unistd.h>
#include <sys/open.h>
#include <sys/cred.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
int main (int argc, char *argv[] )
{
char pid_fn [40] ;
int pid_fs ;
const struct prpsinfo *prps_info ;
int rtn_code ;
sprintf (pid_fn, "/proc/%d", getpid() ) ;
pid_fs = open (pid_fn, FREAD) ;
if (pid_fs == -1)
exit (errno) ;
rtn_code = ioctl (pid_fs, PIOCPSINFO, prps_info) ;
printf ("%s\n", prps_info->pr_fname[PRFNSZ]) ;
return (0) ;
--Quote:} /* end main */
This posting represents the personal opinions of the author. It is not the
official opinion or policy of the author's employer. Warranty expired when you
opened this article and I will not be responsible for its contents or use.