linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: a.biardi@tiscali.it
To: linux-c-programming@vger.kernel.org
Subject: Re: argv[0]
Date: Fri, 24 Feb 2006 14:59:25 +0100	[thread overview]
Message-ID: <200602241459.25477.a.biardi@tiscali.it> (raw)
In-Reply-To: <6a00c8d50601130426u2a9640evc14ee8c3d61c7925@mail.gmail.com>

On Friday 13 January 2006 13:26, you wrote:

> On 1/13/06, a.biardi@tiscali.it <a.biardi@tiscali.it> wrote:
> > Hi,
> >
> > Is there any C function that can tell me what argv[0] is, outside
> > main()?
> >
> > I thought to use getpid() and then look at /proc/<pid>/cmdline
> > but doesn't seem portable. Any hints?
>
> The arguments are pushed on the stack upon process creation.  Once
> the process is running there is little chance to get hands on them
> except for the /proc approach.
>
> 	\Steve
>

Just in case anybody needs it, I think I found something inside 
errno.h (GNU-only):

/* The full and simple forms of the name with which the program was
   invoked.  These variables are set up automatically at startup based
   on  the value of ARGV[0] (this works only if you use GNU ld). */
extern char *program_invocation_name, *program_invocation_short_name;¶

Bye,
Andrea.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2006-02-24 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-12 23:16 argv[0] a.biardi
2006-01-13  9:52 ` argv[0] wwp
2006-01-13 11:52   ` argv[0] a.biardi
2006-01-13 12:19     ` argv[0] Neil Horman
2006-01-13 12:26 ` argv[0] Steve Graegert
2006-02-24 13:59   ` a.biardi [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=200602241459.25477.a.biardi@tiscali.it \
    --to=a.biardi@tiscali.it \
    --cc=linux-c-programming@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).