The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* pid
@ 2005-08-27  7:16 raja
  2005-08-27  7:49 ` pid Gaurav Dhiman
  2005-08-27  7:53 ` pid Willy Tarreau
  0 siblings, 2 replies; 3+ messages in thread
From: raja @ 2005-08-27  7:16 UTC (permalink / raw)
  To: Linux Kernel Mailing List

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);
}


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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pid
  2005-08-27  7:16 pid raja
@ 2005-08-27  7:49 ` Gaurav Dhiman
  2005-08-27  7:53 ` pid Willy Tarreau
  1 sibling, 0 replies; 3+ messages in thread
From: Gaurav Dhiman @ 2005-08-27  7:49 UTC (permalink / raw)
  To: raja; +Cc: Linux Kernel Mailing List

On 8/27/05, raja <vnagaraju@effigent.net> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pid
  2005-08-27  7:16 pid raja
  2005-08-27  7:49 ` pid Gaurav Dhiman
@ 2005-08-27  7:53 ` Willy Tarreau
  1 sibling, 0 replies; 3+ messages in thread
From: Willy Tarreau @ 2005-08-27  7:53 UTC (permalink / raw)
  To: raja; +Cc: Linux Kernel Mailing List

On Sat, Aug 27, 2005 at 12:46:39PM +0530, raja wrote:
> Hi,
>    I am trying to find the pid of the process with out using the 
> getpid() using the following program.

Hmmm, I think you're trying to burn all the steps to programming...
First, your program needs some includes, otherwise it will never
know what struct thread_info and task_struct are made of.
Second, those are kernel structures and functions. There's no where you
can call them from userland.

You should really start from the ground with easier programs to
familiarize with C first.

Regards,
Willy

> 
> int main()
> {
>    struct thread_info * threadInfo = current_thread_info();
>    struct task_struct *taskInfo = threadInfo->task;
>    printf("Pid Is %d\n",taskInfo->pid);
> }
> 
> 
> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-27  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-27  7:16 pid raja
2005-08-27  7:49 ` pid Gaurav Dhiman
2005-08-27  7:53 ` pid Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox