The most obvious thing to pick on is the `goto` statements.
This is not recommended:

- Readability suffers a lot when you make the reader jump around in the code:
  jump forward to see how the conditions was handled,
  then jump back again to see how the variables used there were defined.
  It's a nightmare.

- Poor readability in turn invites more mistakes: when related code segments are far away in the source, you might make a change in one part that breaks the other.

There is a better way to do this: move the code in the labels to the `goto` points, and return there. Simple, and a lot easier to follow what's happening.

Avoid comments whenever possible.
Instead of a comment,
try to code in a way to make the comment unnecessary.
For example:

>     /* This section is never be reached without a goto */

This comment could be replaced with this statement:

    return pid;

Not only this is short and sweet,
it has the great benefit that since it's code,
it will always be enforced.
A comment is powerless.
The code above the original may change in a way that the comment is no longer true,
execution will continue beyond that line,
manifesting in bugs that may be hard to notice.

And we're kind of back to the pesky `goto` statements.
You wouldn't have to worry about writing comments like this or figuring out a better way to do it if you hadn't been using `goto`.