 <p>Did you try some:</p> <pre><code>pid_t pid = getpid(); </code></pre> <p>and try to use gdb to print pid value? Nevertheless, your pid should print. What if you try :</p> <pre><code>printf("pid = %ld\n", getpid()); </code></pre>