Re: [hackers] [sbase][PATCH] flock: call exec without forking

From: Arthur Williams <>
Date: Sun, 6 Mar 2022 10:55:39 -0800

On Sun, Mar 06, 2022 at 10:40:51PM +0600, NRK wrote:
> On Fri, Mar 04, 2022 at 01:11:00AM -0600, Arthur Williams wrote:
> > Previously the code forked, waited for the child to exit and then
> > returned the child's exit code. It is simpler to just skip fork and call
> > exec directly.
> Hi Arthur,
> I didn't comment on this the last time, as I'm not entirely sure if this
> is correct or not myself. However the flock(1) shipped with linux-utils
> has a specific flag to avoid forking, the manpage states:
> -F, --no-fork
> Do not fork before executing command. Upon execution the flock
> process is replaced by command which continues to hold the lock.
> This option is incompatible with --close as there would otherwise
> be nothing left to hold the lock.
> NOTE: `--close` is the `-o` flag.
> - NRK

So I didn't think it mattered in terms of correctness. I was just using
flock in conjunction with my service manager and didn't see the point to
having an extra process waiting per service that wasn't really
providing any benefit. It also cluttered the output of pstree.

Yeah not the most critical of reasons to support a change, but it took
less code/was simpler to just not fork so that seemed to be the more
"suckless" thing to do.

If there is seem deep reason for forking, I'm unaware of it.

Don't believe the '-F' flag is portable so avoided trying to add

- Arthur
Received on Sun Mar 06 2022 - 19:55:39 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 06 2022 - 20:00:39 CET