[PATCH 2/2] first stab at NOFORK applet support

Denis Vlasenko vda at ilport.com.ua
Sat May 6 05:29:28 UTC 2006


On Friday 05 May 2006 19:29, Rob Landley wrote:
> On Friday 05 May 2006 2:41 am, Denis Vlasenko wrote:
> > On Friday 05 May 2006 09:40, Denis Vlasenko wrote:
> > > On Friday 05 May 2006 09:37, Denis Vlasenko wrote:
> > > > Hi Rob,
> > > >
> > > > I looked at implementing NOFORK as discussed a while ago.
> > >
> > > This is a preparatory patch. It changes APPLET macros a bit.
> > > No real code changes.
> > >
> > > Please apply regardless of patch #2.
> >
> > Patch #2 is a meat of the change. Please comment on it.
> > --
> > vda
> 
> Ok...
> 
> It's got unrelated cleanups in there (whitespace, etc) that make it hard to 
> review.

Sorry about that.

> Why is quickshell.h a separate header?

No specific reason for that. Where do you want it to be?

> Why does APPLET_DATA_SIZE have two fields?

Because we may want to handle initialized data in the future in a manner
similar to bss data.

> I really dislike having another table listing all applets.   
> We have a table listing them all, in applets.h.

I will merge quickshell.h to applets.h, no probs.

> Needing to feed a decimal number into APPLET_DATA_SIZE is just evil.

I agree. A better solution is?

> Having to put CHECK_BSS_SIZE() in sed_main() is ugly.

You may omit that, but it's useful compile-time-only check.

> Sticking BEGIN_BSS in the global declarations is black magic.

Well, you need _some form_ of black magic anyway.

> The list of #defines for each global variable is just icky. 

An alternative is to do s/var/B.var/g. This will affect entire body
of the applet, uglifying it a bit.

> Overall, the idea shows promise, but this implementation is opaque and looks 
> really hard to debug and maintain.

> The nofork bit and the global consolidation can be handled separately.  
> Consolidating the globals helps nommu platforms anyway, and is something we 
> should do first.  We can worry about nofork after we've made some headway on 
> that.  I'll convert sed to using a structure to begin with, and see how that 
> looks.

Yes, as you probably noticed, I did not actually do the NOFORK bit itself :)

Consolidating globals consists of consolidating bss and consolidating data.
Data consolidation is done exactly like bss (that is, all data variables are
to be put into a structure) with the addition of one
memcpy(data_buffer, data_template, sizeof(struct DATA))

> (Note: bunzip2 is already using such a structure, although if we  
> consolidate that and tar tries to use it without forking...)

Prime candidates for NOFORK'ifying are those applets which may be
frequently used in shell scripts in loops: cat, cp, mv, mkdir, cut,
awk, sed, grep, basename, ...
tar is not one of them.

> If we have to prefix the names of structure types used in globals to avoid 
> namespace collision, we'll live.
> 
> Rummage rummage...  You know, sed's struct append_list can just go away, since 
> we've _got_ a linked list type now...  (Hums to self, banging away on sed 
> code...)
--
vda



More information about the busybox mailing list