gnunet-developers
[Top][All Lists]
Advanced

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

Re: GNUNET_OS_start_process and process arguments


From: Martin Schanzenbach
Subject: Re: GNUNET_OS_start_process and process arguments
Date: Mon, 14 Dec 2020 01:10:27 +0900
User-agent: Evolution 3.38.1 (3.38.1-1.fc33)

I do not understand why it is intentional.
I also do not understand what exec has to do with it.
exec does not behave like that:

$ exec ./a.out hello w
[./a.out] [hello] [w]

BR

On Sun, 2020-12-13 at 16:54 +0100, Christian Grothoff wrote:
> That's intentional. Same as with 'exec'. First argument is the file
> name/path to the binary, and argv[0] is separate. See 'exec'. In
> general, simply pass the binary name twice.
> 
> -Christian
> 
> On 12/13/20 4:32 PM, Alessio Vanni wrote:
> > Hello,
> > 
> > I noticed a curious situation, best explained by this example:
> > 
> > Let's say I have a program (let's call it 'gnunet-exec') that
> > starts a
> > process using `GNUNET_OS_start_process', with the program file name
> > taken from the command line and using the two strings "hello" and
> > "world" as arguments to the process.
> > 
> > Let's also say I have this small program:
> > 
> > int main(int argc, char *argv[]) {
> >     printf("[%s] [%s] [%s]\n", argv[0], argv[1], argv[2]);
> >     return 0;
> > }
> > 
> > I then get this result ($ is the shell prompt):
> > 
> > $ ./small-program hello world
> > [small-program] [hello] [world]
> > 
> > $ gnunet-exec small-program
> > [hello] [world] [(null)]
> > 
> > Essentially, argv[0] becomes the first argument instead of
> > containing
> > the program name.
> > 
> > Is this intentional or is it a bug?
> > 
> > Thanks,
> > A.V.
> > 
> 

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]