All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <willy@w.ods.org>
To: raja <vnagaraju@effigent.net>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: pid
Date: Sat, 27 Aug 2005 09:53:28 +0200	[thread overview]
Message-ID: <20050827075328.GD10110@alpha.home.local> (raw)
In-Reply-To: <43101357.7060103@effigent.net>

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/

      parent reply	other threads:[~2005-08-27  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-27  7:16 pid raja
2005-08-27  7:49 ` pid Gaurav Dhiman
2005-08-27  7:53 ` Willy Tarreau [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050827075328.GD10110@alpha.home.local \
    --to=willy@w.ods.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vnagaraju@effigent.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.