MCPcopy Create free account
hub / github.com/Alexays/Waybar / handleSignalMainThread

Function handleSignalMainThread

src/main.cpp:118–155  ·  view source on GitHub ↗

Must be called on the main thread. If this signal should restart or close the bar, this function will write `true` or `false`, respectively, into `reload`.

Source from the content-addressed store, hash-verified

116// If this signal should restart or close the bar, this function will write
117// `true` or `false`, respectively, into `reload`.
118static void handleSignalMainThread(int signum, bool& reload) {
119 if (signum >= SIGRTMIN + 1 && signum <= SIGRTMAX) {
120 for (auto& bar : waybar::Client::inst()->bars) {
121 bar->handleSignal(signum);
122 }
123 return;
124 }
125
126 switch (signum) {
127 case SIGUSR1:
128 handleUserSignal(SIGUSR1, reload);
129 break;
130 case SIGUSR2:
131 handleUserSignal(SIGUSR2, reload);
132 break;
133 case SIGINT:
134 spdlog::info("Quitting.");
135 reload = false;
136 waybar::Client::inst()->reset();
137 break;
138 case SIGCHLD:
139 spdlog::debug("Received SIGCHLD in signalThread");
140 if (!reap.empty()) {
141 reap_mtx.lock();
142 for (auto it = reap.begin(); it != reap.end(); ++it) {
143 if (waitpid(*it, nullptr, WNOHANG) == *it) {
144 spdlog::debug("Reaped child with PID: {}", *it);
145 it = reap.erase(it);
146 }
147 }
148 reap_mtx.unlock();
149 }
150 break;
151 default:
152 spdlog::debug("Received signal with number {}, but not handling", signum);
153 break;
154 }
155}
156
157int main(int argc, char* argv[]) {
158 try {

Callers 1

mainFunction · 0.85

Calls 6

handleUserSignalFunction · 0.85
handleSignalMethod · 0.80
resetMethod · 0.80
emptyMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected