Skip navigation.
Home
The QNX Community Portal

View topic - Get processes states

Get processes states

Discussion about the QNX6 OS.

Get processes states

Postby olivier_g » Tue Feb 17, 2015 10:27 am

Hi

I want to obtain some processes states RECEIVE, DEAD, REPLY (like pidin)

I wrote some code
procfs_status my_status;
memset(&my_status, 0x0, sizeof (my_status));
sts = devctl( fd, DCMD_PROC_STATUS, &my_status, sizeof(my_status), NULL);

devctl return state is OK but my_status.state is always 0 which mean DEAD

Where is the problem ?

Thank

Olivier
olivier_g
New Member
 
Posts: 3
Joined: Tue Feb 10, 2015 9:06 am

Re: Get processes states

Postby Tim » Tue Feb 17, 2015 8:41 pm

We need to see the rest of your code. Specifically how you are filling out your fd value.

Here's some sample code from the QNX doc's. Your code should look something like this replacing DCMD_PROC_MAPDEBUG_BASE with your DCMD_PROC_STATE.


Code: Select all
int
display_process_info(pid_t pid)
{
    char            buf[PATH_MAX + 1];
    int             fd, status;
    struct dinfo_s  dinfo;
    procfs_greg     reg;

    printf("%s: process %d died\n", progname, pid);

    sprintf(buf, "/proc/%d/as", pid);

    if ((fd = open(buf, O_RDONLY|O_NONBLOCK)) == -1)
        return errno;

    status = devctl(fd, DCMD_PROC_MAPDEBUG_BASE, &dinfo,
                    sizeof(dinfo), NULL);
    if (status != EOK) {
        close(fd);
        return status;
    }

    printf("%s: name is %s\n", progname, dinfo.info.path);

    /*
     * For getting other type of information, see sys/procfs.h,
     * sys/debug.h, and sys/dcmd_proc.h
     */
     
    close(fd);
    return EOK;
}


Tim
Tim
Senior Member
 
Posts: 1389
Joined: Wed Mar 10, 2004 12:28 am

Re: Get processes states

Postby olivier_g » Thu Feb 19, 2015 3:08 pm

The entire code is

sprintf (paths, "/proc/%d/as", pid);

if ((fd = open (paths, O_RDONLY)) == -1)
{
printf("erreur open %s \n", paths);
return;
}

procfs_status my_status;
memset(&my_status, 0x0, sizeof (my_status));
sts = devctl( fd, DCMD_PROC_STATUS, &my_status, sizeof(my_status), NULL);
if (sts != EOK)
{
fprintf(stderr, "DCMD_PROC_STATUS pid %d errno %d (%s)\n", pid, errno, strerror (errno));
}
else
{
printf("DCMD_PROC_STATUS pid %d state %d priority %d\n",pid, my_status.state ,my_status.priority);
}
I iterate all the processes. sts is EOK but my_status.state is aways 0 (DEAD)
olivier_g
New Member
 
Posts: 3
Joined: Tue Feb 10, 2015 9:06 am

Re: Get processes states

Postby Tim » Thu Feb 19, 2015 5:07 pm

OK, I tried and got same results as you.

However I figured out pretty quickly that getting Process info isn't going to get you thread data. What you really want is

my_status.tid = 1;
devctl( fd, DCMD_PROC_TIDSTATUS, &my_status, sizeof(my_status), NULL);

That gets the individual thread info. I tried this and immediately got the state/priority fields etc for the threads in a process. So you need to change your call and iterate through the threads in each process by supplying the id (tid).

Tim
Tim
Senior Member
 
Posts: 1389
Joined: Wed Mar 10, 2004 12:28 am


Return to QNX6 - OS

Who is online

Users browsing this forum: No registered users and 4 guests

cron