mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-22 00:28:30 -04:00
desktop: exit if loop() doesn't run for 5 seconds
this should stop runaway processes
This commit is contained in:
parent
47ef43ad08
commit
0820ff52a8
@ -5,6 +5,7 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <wiring.h>
|
#include <wiring.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <signal.h>
|
||||||
#include "desktop.h"
|
#include "desktop.h"
|
||||||
|
|
||||||
void setup(void);
|
void setup(void);
|
||||||
@ -20,6 +21,12 @@ static void usage(void)
|
|||||||
printf("\t-w wipe eeprom and dataflash\n");
|
printf("\t-w wipe eeprom and dataflash\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sig_alarm(int sig)
|
||||||
|
{
|
||||||
|
printf("alarm signal in desktop emulation - loop not running\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char * const argv[])
|
int main(int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
@ -43,6 +50,9 @@ int main(int argc, char * const argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal(SIGALRM, sig_alarm);
|
||||||
|
alarm(5);
|
||||||
|
|
||||||
// run main setup() function from sketch
|
// run main setup() function from sketch
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@ -51,6 +61,8 @@ int main(int argc, char * const argv[])
|
|||||||
fd_set fds;
|
fd_set fds;
|
||||||
int fd_high = 0;
|
int fd_high = 0;
|
||||||
|
|
||||||
|
alarm(5);
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(0, &fds);
|
FD_SET(0, &fds);
|
||||||
loop();
|
loop();
|
||||||
|
Loading…
Reference in New Issue
Block a user