[LTP] [PATCH 2/2] tst_test: using SIGTERM to terminate process

Joerg Vehlow lkml@jv-coder.de
Mon May 31 15:16:42 CEST 2021


Hi Cyril,

On 5/31/2021 2:35 PM, Cyril Hrubis wrote:
> Hi!
>> But one more strange thing here.
>> I wonder why this even works. $pid is used in _tst_kill_test and defined
>> in _tst_setup_timer as a local variable.
>> It looks like it is inherited through the call chain and since it is
>> copied to the background process, it cannot be manipulated by the tests.
>> Still I would vote for changing this at some point, because it is highly
>> confusing.
> That's actually a correct and well defined behavior, if you call a
> function g from function f the function g has access to the variables
> local to f.
>
> And yes it's confusing, but the alternative is having another global
> variable which I do not think is much better than this.
Hm shell code has more strange behavior than I would have ever expected...
But at least Li and myself did not know that and even while you know 
about this "feature", you think it is strange.
I would rather like to be explicit and use a global variable (what harm 
is it really?) instead of confusing the next one looking at this piece 
of code....

Jörg


More information about the ltp mailing list