2 Comments

  1. Please update the reuslt section with actual result.

    $ gcc getpid.c -o s && ./s
    ppid: 7108

    But printf is
    printf(“pid: %lun”, pid);

    How come it prints “ppid” for print statement of “pid”.

  2. Hello, thanks for the idea but getpid() returns an int so the format in printf is abnormal : %lun should be just %d (and the n in lun is probably a typo)

    the error :
    error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘pid_t’ {aka ‘int’}

    x86_64 architecture, 64 bits

Leave a Reply

Your email address will not be published. Required fields are marked *