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: Christian Grothoff
Subject: Re: GNUNET_OS_start_process and process arguments
Date: Sun, 13 Dec 2020 16:54:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

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: OpenPGP digital signature


reply via email to

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