Hi,
I wrote a simple kernel module to play with the process descriptor structure of a process. I have given the code below.
int init_module(void)
{
printk(KERN_INFO "Hello Process \n");
printk(KERN_INFO "Parent process ID :%d \n",current->parent->pid);
printk(KERN_INFO "Parent process state :%d \n",current->parent->state);
printk(KERN_INFO "Parent process uid :%d \n",current->parent->uid);
printk(KERN_INFO "Parent process priority :%d \n",current->parent->prio);
/* Change the parent process state to unrannable */
current->parent->state= -1;
return 0;
}
By this code, I am trying to print the details of the parent process of the current process ( current process is insmod and its parent process is the bash shell from which I issued insmod command, if I am not wrong ). Also I try to change the state of the bash shell to -1 ( unrunnable ).
I see that the current->parent->state is printed as 1 . I see that process state > 0 is stopped , as defined in "struct task_struct". Then why it is printed as 1 when the bash shell is actually running ?
Also by changing the state of the bash shell to -1, I expected it to hang or something like that. But that did not happen.
Could anyone please let me know what is wrong with my approach..?
Thanks,
Rajaram.
I wrote a simple kernel module to play with the process descriptor structure of a process. I have given the code below.
int init_module(void)
{
printk(KERN_INFO "Hello Process \n");
printk(KERN_INFO "Parent process ID :%d \n",current->parent->pid);
printk(KERN_INFO "Parent process state :%d \n",current->parent->state);
printk(KERN_INFO "Parent process uid :%d \n",current->parent->uid);
printk(KERN_INFO "Parent process priority :%d \n",current->parent->prio);
/* Change the parent process state to unrannable */
current->parent->state= -1;
return 0;
}
By this code, I am trying to print the details of the parent process of the current process ( current process is insmod and its parent process is the bash shell from which I issued insmod command, if I am not wrong ). Also I try to change the state of the bash shell to -1 ( unrunnable ).
I see that the current->parent->state is printed as 1 . I see that process state > 0 is stopped , as defined in "struct task_struct". Then why it is printed as 1 when the bash shell is actually running ?
Also by changing the state of the bash shell to -1, I expected it to hang or something like that. But that did not happen.
Could anyone please let me know what is wrong with my approach..?
Thanks,
Rajaram.
Yahoo! for Good - Make a difference this year.