Operating System - Tru64 Unix
1748243 Members
4053 Online
108760 Solutions
New Discussion юеВ

Tru64 proc file system with ioctl call

 
Roopa V
Occasional Advisor

Tru64 proc file system with ioctl call

Hi,

In Linux, the process command line arguments can be accessed using /proc file system. Here, the file "/proc//cmdline" contains the command line arguments of the process. How to access the command line arguments of a running process in Tru64? Is it possible to read it through ioctl() with proc()

Thanks,
Roopa
4 REPLIES 4
Martin Moore
HPE Pro

Re: Tru64 proc file system with ioctl call

ps -o args, in conjunction with whatever other flags you like. For example, to see the args that xntpd was started with:

% ps -e -o pid,ppid,cmd,args | grep xntpd
525367 524289 /usr/sbin/xntpd /usr/sbin/xntpd -g -x -c /etc/ntp.conf
843798 843880 grep xntpd grep xntpd

Martin

I work for HPE
A quick resolution to technical issues for your HPE products is just a click away HPE Support Center
See Self Help Post for more details

Accept or Kudo

Roopa V
Occasional Advisor

Re: Tru64 proc file system with ioctl call

Thanks Martin.

I need to write a C application to get the command line arguments of a given process id.
But I do not want to rely on -
popen("ps -eo pid,args | grep ") or system("ps -eo pid,args | grep ") call. Can we read command line arguments using proc() on Tru64?

Thanks,
Roopa
Martin Moore
HPE Pro

Re: Tru64 proc file system with ioctl call

I strongly doubt that you can do it through /proc as such; the function of /proc in Tru64 is quite different than it is in Linux. But all you really need is some way to retrieve the command line arguments in C. In that case, you should be able to do it with the table() system call, which lets you retrieve various tables of information about processes. See man table(2) for tons of information.

If you specify TBL_ARGUMENTS as the desired table, it should do just what you need:

"...This table contains all the command line arguments for the process. Specify the process id in the index argument. The addr argument points to a buffer into which the command line arguments are placed."

Martin



I work for HPE
A quick resolution to technical issues for your HPE products is just a click away HPE Support Center
See Self Help Post for more details

Accept or Kudo

Roopa V
Occasional Advisor

Re: Tru64 proc file system with ioctl call

Thanks again Martin. I tried using table() system call. But I'm able to retrieve only argv[0]. Please find my sample program below which I tried.

/*
* Sample program to retrieve command line arguments of a running process
* on Tru64 using table() system call.
*/
#include
#include
#include

#define MAX_BUF_SIZE 1024

int main(int argc, char *argv[])
{
char arg_list[MAX_BUF_SIZE];
char *nextp = NULL;
int mypid = getpid();
int len = 0;

len = table(TBL_ARGUMENTS, mypid, arg_list, 1, MAX_BUF_SIZE);
if (len >= 0) {
nextp = arg_list;
while (nextp < arg_list + len) {
printf("%s\t", nextp);
nextp += strlen(nextp) + 1;
}
}
else {
perror("table");
}
return 0;
}


Thanks,
Roopa