[Toybox] Fix, killall is not allowed to kill itself

Rob Landley rob at landley.net
Sun Dec 23 13:29:40 PST 2012


On 12/23/2012 02:45:57 PM, Elie De Brauwer wrote:
> On 12/23/2012 09:42 PM, Rob Landley wrote:
>> On 12/16/2012 11:12:59 AM, Elie De Brauwer wrote:
>>> All,
>>> 
>>> In my previous patch, the pif shouldn't be stored inside the  
>>> GLOBAL(), it
>>> should be just a regular global variable. In attach a patch which
>>> corrects this.
>> 
>> Ok, I finally took a proper look at this, and I don't understand why
>> can't we have pid_t in GLOBALS()? It's a standard type, it's not  
>> being
>> used as an argument target (in which case it would have to be a  
>> long),
>> the #includes in toys.h give us that type...
>> 
>> Could you explain your reasoning? (In the meantime, I've applied your
>> first patch.)
> 
> Mea culpa, I thought GLOBALS() was only meant for command line  
> parsing,
> but apparently it isn't.

The first few entries in GLOBALS have to match up with the option  
string's use of it (if any), but everything after that is just normal  
global variables (initialized to 0).

I usually mark this by putting a blank line between the last option  
slot and the first non-option global, when it's got both in there.

The advantage of GLOBALS() is the same memory gets used for all  
commands (union of structures), so we're not allocating a huge bss. It  
also means that if a command has to call another command it can memset  
the globals block and be sure that everything starts in the same  
initial state even if it's been run more than once since exec().  
(Useful for toysh().)

Rob
 1356298180.0


More information about the Toybox mailing list