That was it - after issuing the shutdown command I had put the program on 
an endless loop with a usleep; instead, the service now exits right after 
issuing the reboot command the reboot indeed occurs as before, within 8 
seconds or so.

Thank you!


On Thursday, June 2, 2016 at 6:34:13 PM UTC-4, john3909 wrote:
>
> My guess is your systemd service isn’t exiting and so the shutdown pauses 
> until your service exits or after a timeout, the service is sent a kill 
> signal to exit. 
>
> Regards,
> John
>
>
>
>
> On Jun 2, 2016, at 3:28 PM, YP66 <[email protected] <javascript:>> wrote:
>
> I am working on an automatic shutdown based on an external signal (through 
> a digital IO line), on a BB black, running Debian Jessie.
>
> I build a program that monitors the digital line and when that line goes 
> high, the program calls
>     system("/sbin/shutdown -h now");
>
> When I run that program interactively, it takes anywhere between 6 to 10 
> seconds to shutdown following the digital line flip.  I use an LED to tell 
> me when the process detects the bit flip so I can reliably count the time 
> to shutdown.  The actual shutdown is evident because all the lights go off. 
>  At that point I have to recycle power to start again, which is exactly 
> what I want.
>
> However, when I put the same program to run as a service (by adding a 
> service in /lib/systemd/ and using systemctl to start it), the system takes 
> over 30 seconds to shutdown, sometimes a minute or two.  I know the program 
> is running as a service because I can see the LED I am using as feedback. 
>  The LED changes blink rate when the 'service' detects the GPIO change so I 
> can tell the program is getting to the point of making the system call, it 
> just takes so much longer.  In fact, initially I thought it did not work, 
> only to have the system shutdown on my suddenly a couple of minutes later.
>
> So the situation is that a program running directly goes through a 
> shutdown almost instantaneously but when run through a service, it takes 
> significantly longer.  Any idea why?
>
> By the way, I have also tried 
>
>    sync();
>    reboot(LINUX_REBOOT_CMD_POWER_OFF);
>
> instad of system("/sbin/shutdown -h now'), and I get more or less the same 
> behavior.
>
>
>
> -- 
> For more options, visit http://beagleboard.org/discuss
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beagleboard/501fb3a7-bdae-4b3e-96ad-3df2a8c67d0e%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/beagleboard/501fb3a7-bdae-4b3e-96ad-3df2a8c67d0e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/39106676-0f70-4dbf-95cf-a9f3eca9480f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to