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