rt-thread-official/components/libc/compilers/common/stdlib.c

46 lines
852 B
C
Raw Normal View History

2021-02-17 00:02:28 +08:00
/*
2021-03-08 18:19:04 +08:00
* Copyright (c) 2006-2021, RT-Thread Development Team
2021-02-17 00:02:28 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-02-15 Meco Man first version
*/
#include <rtthread.h>
2021-09-28 03:53:21 +08:00
#define DBG_TAG "stdlib"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
2021-02-17 23:50:12 +08:00
void __rt_libc_exit(int status)
2021-02-17 00:02:28 +08:00
{
rt_thread_t self = rt_thread_self();
if (self != RT_NULL)
{
2021-09-28 03:53:21 +08:00
LOG_E("thread:%s exit:%d!", self->name, status);
rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL);
2021-02-17 00:02:28 +08:00
}
}
2021-09-28 03:53:21 +08:00
#ifdef RT_USING_MSH
2021-09-28 10:20:21 +08:00
int system(const char *command)
{
2021-09-28 03:53:21 +08:00
extern int msh_exec(char *cmd, rt_size_t length);
2021-09-28 10:20:21 +08:00
int ret = -RT_ENOMEM;
char *cmd = rt_strdup(command);
if (cmd)
{
ret = msh_exec(cmd, rt_strlen(cmd));
rt_free(cmd);
}
return ret;
2021-02-17 00:02:28 +08:00
}
2021-09-28 10:20:21 +08:00
RTM_EXPORT(system);
#endif