On Fri, 17 Feb 2017, Ossi Herrala wrote: > ping? Sorry about that; life has been busy.
> On Sun, Feb 12, 2017 at 07:58:27PM +0200, Ossi Herrala wrote: > > On Sun, Feb 12, 2017 at 01:34:14AM +0200, Ossi Herrala wrote: > > > > > After couple of private mails with guenther@ we came up with the > > > following patch. > > > > > > Introduce new flag FORK_PID1 for fork1(9). > > > > > > This flag is special and only for forking init(8) which wants to be > > > PID 1. > > > > > > With this flag in place, it's possible to remove global randompid > > > variable which was used to control if allocpid() returns random PIDs > > > or PID 1 for init(8). Now allocpid() can also be simplified. > > > > New patch which works with latest changes to fork1(9). > > > > This version also documents FORK_PID1 flag in fork1(9) man page. I've now gone back and forth on this diff a few times. I like the simplfication of allocpid(), but then it seems like deck-chair shuffling as the test is just moved to another function. But eliminating the magic-at-a-distance randompid frobbing is nice, as is making it clear that there's really only one PID that will ever be special. Indeed, it would even allow kthreads to be created before init (though what _else_ they depend on is unclear...). Maybe setting the USB tasks loose earlier would be useful, for example. Hmm. Since I'm so mixed, do any other devs have an opinion? > > --- a/share/man/man9/fork1.9 > > +++ b/share/man/man9/fork1.9 > > @@ -109,6 +109,9 @@ must also be set. > > .It Dv FORK_PTRACE > > The child will start with tracing enabled, as if > > ptrace(PT_TRACE_ME, 0, 0, 0) had been invoked in the child. > > +.It Dv FORK_PID1 > > +Special flag to assign PID 1 for > > +.Xr init 8 process. I think this would be a nice place to explicitly mention the default is a random pid, perhaps: .It Dv FORK_PID1 The child is .Xr init 8 and is assigned PID 1 instead of a random PID. Philip