Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4594897

Browse files
committed
Fix: Handle signals properly also in servo_map bin
1 parent b83d3af commit 4594897

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/bin/servo_map.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// along with servoarray. If not, see <http://www.gnu.org/licenses/>.
1515

1616
#include "servoarray/servomap.h"
17+
#include "./util.h"
1718

1819
#include <iostream>
1920

@@ -23,6 +24,10 @@ int main(int argc, char **argv) {
2324
auto sa = ServoArray::ServoArray(driver);
2425
auto map = ServoArray::ServoMap(sa);
2526

27+
util::register_signal(SIGINT);
28+
util::register_signal(SIGQUIT);
29+
util::register_signal(SIGTERM);
30+
2631
while(true) {
2732
std::string name;
2833
std::cout << "(name) > ";
@@ -34,5 +39,7 @@ int main(int argc, char **argv) {
3439

3540
map[name] = rad;
3641
std::cout << name << " -> " << map[name] << std::endl;
42+
43+
if(util::should_exit()) break;
3744
}
3845
}

0 commit comments

Comments
 (0)