You can send a signal to all process with signal ( pid, SIGPWR ) and signal ( pid, SIGTERM ).
However I find this method to be a little to violent. First kill all your own process then umount all devices, no need to kill the drivers, unmouting them is a lot cleaner and safe.
You don’t need any other processes to use in8 out8. However most program have stdin/stdout/stderr, so the program that kills everything must close all handles first before killing such process as devc-con (which I don’t see any reason to kill in the first place). Your program should also start its own session otherwise kill the parent shell will kill your program as well (but again I don’t see the point in killing the shells)
What about calling function:
[color=darkred] system(“shutdown -fb”);
command shutdowns system in time approx. 2 seconds. So you can before calling this send command to serial interface. Your serial interface must wait for 3 seconds before switching your relay to switch computer OFF. You can use famous integrated circuit “555” do wait 3 seconds…