/** * Stops all the running processes, if any */ void bb_stop_all(void) { bb_log(LOG_DEBUG, "Killing all remaining processes.\n"); /* keep killing the first program in the list until it's empty */ while (pidlist_start) { bb_stop_wait(pidlist_start->PID); } }
/** * Kill the second X server if any, turn card off if requested. */ void stop_secondary() { char driver[BUFFER_SIZE]; // kill X if it is running if (bb_is_running(bb_status.x_pid)) { bb_log(LOG_INFO, "Stopping X server\n"); bb_stop_wait(bb_status.x_pid); } if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) { /* do not disable the card if PM is disabled unless exiting */ return; } //if card is on and can be switched, switch it off if (switcher) { if (switcher->need_driver_unloaded) { /* do not unload the drivers nor disable the card if the card is not on */ if (switcher->status() != SWITCH_ON) { return; } if (pci_config_save(pci_bus_id_discrete, &pci_config_state_discrete)) { bb_log(LOG_WARNING, "Could not save PCI configuration space: %s\n", strerror(errno)); } /* unload the driver loaded by the graphica card */ if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) { module_unload(driver); } //only turn card off if no drivers are loaded if (pci_get_driver(NULL, pci_bus_id_discrete, 0)) { bb_log(LOG_DEBUG, "Drivers are still loaded, unable to disable card\n"); return; } } if (switch_off() != SWITCH_OFF) { bb_log(LOG_WARNING, "Unable to disable discrete card."); } } }//stop_secondary