Re: pid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/27/05, raja <[email protected]> wrote:
> Hi,
>     I am trying to find the pid of the process with out using the
> getpid() using the following program.
> 
> int main()
> {
>     struct thread_info * threadInfo = current_thread_info();
>     struct task_struct *taskInfo = threadInfo->task;
>     printf("Pid Is %d\n",taskInfo->pid);
> }

You are writting a user space programme and in that you can not use
the kernel data structures. Usually user programmes communicate wth
kernel through system calls. The thing you are doing is not allowed.
If you are a kernelnewbie, I would recommend you to subscribe to
kernelnewbies mailing list.

regards,
-Gaurav

> 
> 
> And when i try to compile using
> gcc  -Wall  pid.c
> 
> Then I am getting so many errors like
> 
> 
> pid.c:9: warning: implicit declaration of function `current_thread_info'
> pid.c:9: warning: initialization makes pointer from integer without a cast
> pid.c:10: error: dereferencing pointer to incomplete type
> pid.c:11: error: dereferencing pointer to incomplete type
> 
> 
> 
> Will you please help me.
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux