I had a problem with a wireless network using wpa_supplicant. When a connection is lost on the wireless network then the connection will not be re-established. So after hours of investigation I found out how to fix the problem. As I originally suspected it was a bug with the baselayout scripts. I got the latest version of baselayout (1.12.0_pre17-r2) and the problem still exists in this version. The problem occurs in the /lib/rcscripts/net.modules.d/dhcpcd.sh file, line 60. start-stop-daemon is used instead of the /sbin/start-stop-daemon. Using the start-stop-daemon function defined in /lib/rcscripts/sh/rc-daemon.sh to kill a process without creating the process (as is done in dhcpd.sh) causes the /var/lib/init.d/daemons/net.xxx file to lose reference to the wpa_supplicant process. When this occurs the code in the /lib/rcscripts/net.modules.d/wpa_supplicant.sh module kills the wpa_supplicant process when the wifi connection is lost. And thus no more wifi. If you edit the dhcpcd.sh file and change start-stop-daemon to /sbin/start-stop-daemon then the cascade of failure will not occur and the wifi connection will reestablish after the wifi connection is temporarily lost. Actually there is also a bug in the start-stop-daemon function which removed the reference to wpa_supplicant when start-stop-daemon --kill was called with reference to dhcpcd. I'm not sure exactly why the start-stop-daemon is failing because this is really the first time that I tried debugging a bash script and I did so by inserting logger statements throughout the rc-scripts. I've only really started understanding bash for a few months now. Hope this helps.
Problem confirmed. The proposed solutions works for me, thank you for investigating this.
Created attachment 84888 [details, diff] Patch rc-daemon.sh to only remove what we asked for Attached is a patch to /lib/rcscripts/sh/rc-daemon.sh that should correct this issue. The patch references sbin/rc-daemon.sh so it can easily be applied to the ebuild - to manually patch it, change it to reference /lib/rcscripts/sh/rc-daemon.sh
Please test and report back.
(In reply to comment #3) > Please test and report back. Appears to work here as well (tested with the original proposed fix reverted, of course). Joseph, does this work for you as well?
(In reply to comment #4) > Appears to work here as well (tested with the original proposed fix reverted, > of course). > > Joseph, does this work for you as well? > I've re-emerged this baselayout package, applied the patch to the rc-daemon.sh script and performed the original tests that led me to discover the problem. /var/lib/init.d/daemons/net.eth1 had the correct information this time around and the connection was re-established with my wireless access point after I switched it off and on, without restarting the service on my laptop. Classic == bug hey... Someone once gave me a great C tip which may apply to bash: He said to use the form constant == variable instead of the conventional method of variable == constant. This way, if human nature sucumbes then a compile error will occur instead of a phantom intermittent type bug.
(In reply to comment #5) > Classic == bug hey... Someone once gave me a great C tip which may apply to > bash: He said to use the form constant == variable instead of the conventional > method of variable == constant. This way, if human nature sucumbes then a > compile error will occur instead of a phantom intermittent type bug. Ah no, bash treats quoting differently with RHS vs LHS. Besides, that makes code more unreadable imo.
Fixed in pre17-r3