Re: [dev] [st] [PATCH 1/2] Do not use switch for fork() call.

From: <noname_AT_inventati.org>
Date: Mon, 13 Apr 2015 10:59:46 +0000

On Mon, Apr 13, 2015 at 09:20:34AM +0200, Roberto E. Vargas Caballero wrote:
> I don't understand this patch. The switch-fork is a common idiom
> and I don't know why you think it should be changed.

It separates the case when fork fails and when fork succeeds. You can
even move error-processing code to something like xfork().

First, we die if fork failed.
If fork succeeds, we continue and have branches for child (pid == 0) and
parent (pid == child).

With switch, we have branches for failed parent, child and suceeded
parent, in this order.

Also, the code is obviously shorter.
Received on Mon Apr 13 2015 - 12:59:46 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 13 2015 - 13:12:05 CEST