On 2013-11-23 17:09, Bastian Bittorf wrote: > * Yousong Zhou <[email protected]> [23.11.2013 17:01]: >> > was puzzles me: the "PID_inside" is the same like from the main-script. >> > should'nt it change? >> >> It's weird. I found the following description from bash manual [1] that >> `$$`: >> >> Expands to the process ID of the shell. In a () subshell, it >> expands to the process ID of the current shell, not the sub‐ >> shell. > > thanks for digging into this: > so it's really a subshell when running in ( . $script ) > and maybe we can avoid this. > >> > i also found, that it is possible to simply change all calls to "exit" >> > to a "return", so the sourcing of a script will be aborted and no >> > subshell is needed anymore. >> > >> > this must be somehow "enforced" by the openwrt-build: all files in >> > "/etc/hotplug.d/"* cannot have the keyword "exit" in there 8-) otherwise >> > we break the execution of further calls in the loop... >> >> I agree with you. Script handlers for the same event should not >> intervene with each other. > > ok, i'am ok with changing all those scripts - it's not easy > to find them because they are not "marked" somehow and not > neccessary in /etc/hotplug.d/ - but i will find a way to identify > them. for the devs: are you OK with such a change?: > > first update all hotplug-scripts to work without 'exit', then > change the /sbin/hotplug-call to '. $script' instead of ( . $script ) I disagree with the proposal to get rid of subshells here. I don't want one hotplug script to accidentally pick up variables of another one, because such issues can be annoying to debug, and a tiny micro-optimization of shell code simply isn't worth dealing with this.
- Felix _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
