mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
Posix: add '#pragma GCC poison exit'
Generally exit() should not be used on Posix, because it exits the whole program instead of only the task.
This commit is contained in:
@@ -330,7 +330,7 @@ Client::_sig_handler(int sig_num)
|
|||||||
|
|
||||||
if (_client_send_pipe_fd < 0) {
|
if (_client_send_pipe_fd < 0) {
|
||||||
PX4_ERR("pipe open fail");
|
PX4_ERR("pipe open fail");
|
||||||
exit(-1);
|
system_exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bytes_to_send = get_client_send_packet_length(&packet);
|
int bytes_to_send = get_client_send_packet_length(&packet);
|
||||||
@@ -338,7 +338,7 @@ Client::_sig_handler(int sig_num)
|
|||||||
|
|
||||||
if (bytes_sent != bytes_to_send) {
|
if (bytes_sent != bytes_to_send) {
|
||||||
PX4_ERR("write fail");
|
PX4_ERR("write fail");
|
||||||
exit(-1);
|
system_exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ void
|
|||||||
px4_systemreset(bool to_bootloader)
|
px4_systemreset(bool to_bootloader)
|
||||||
{
|
{
|
||||||
PX4_WARN("Called px4_system_reset");
|
PX4_WARN("Called px4_system_reset");
|
||||||
exit(0);
|
system_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, px4_main_t entry,
|
px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, px4_main_t entry,
|
||||||
|
|||||||
@@ -59,6 +59,18 @@
|
|||||||
# define __END_DECLS
|
# define __END_DECLS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* exit() is used on NuttX to exit a task. However on Posix, it will exit the
|
||||||
|
* whole application, so we prevent its use there. There are cases where it
|
||||||
|
* still needs to be used, thus we remap system_exit to exit.
|
||||||
|
*/
|
||||||
|
#define system_exit exit
|
||||||
|
#ifdef __PX4_POSIX
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <cstdlib>
|
||||||
|
#endif
|
||||||
|
#pragma GCC poison exit
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __PX4_NUTTX
|
#ifdef __PX4_NUTTX
|
||||||
/* On NuttX we call clearenv() so we cannot use getenv() and others (see px4_task_spawn_cmd() in px4_nuttx_tasks.c).
|
/* On NuttX we call clearenv() so we cannot use getenv() and others (see px4_task_spawn_cmd() in px4_nuttx_tasks.c).
|
||||||
|
|||||||
+1
-1
Submodule src/lib/DriverFramework updated: 3bdfdf3db2...b439556d54
@@ -87,7 +87,7 @@ public:
|
|||||||
|
|
||||||
void task_main();
|
void task_main();
|
||||||
|
|
||||||
void exit() { _force_task_exit = true; }
|
void exit_task() { _force_task_exit = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void publish_led_control(led_control_s &led_control);
|
void publish_led_control(led_control_s &led_control);
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <string.h> /* memset, etc */
|
#include <string.h> /* memset, etc */
|
||||||
#include <stdlib.h> /* exit */
|
#include <stdlib.h> /* exit */
|
||||||
|
|
||||||
#define oom() exit(-1)
|
// FIXME: this needs to be checked: we need to handle OOM properly instead of just exiting
|
||||||
|
#define oom() system_exit(-1)
|
||||||
|
|
||||||
typedef void (ctor_f)(void *dst, const void *src);
|
typedef void (ctor_f)(void *dst, const void *src);
|
||||||
typedef void (dtor_f)(void *elt);
|
typedef void (dtor_f)(void *elt);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void list_builtins(apps_map_type &apps)
|
|||||||
int shutdown_main(int argc, char *argv[])
|
int shutdown_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("Shutting down\n");
|
printf("Shutting down\n");
|
||||||
exit(0);
|
system_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int list_tasks_main(int argc, char *argv[])
|
int list_tasks_main(int argc, char *argv[])
|
||||||
|
|||||||
Reference in New Issue
Block a user