1
0

stdlib.c 852 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-02-15 Meco Man first version
  9. */
  10. #include <rtthread.h>
  11. #define DBG_TAG "stdlib"
  12. #define DBG_LVL DBG_INFO
  13. #include <rtdbg.h>
  14. void __rt_libc_exit(int status)
  15. {
  16. rt_thread_t self = rt_thread_self();
  17. if (self != RT_NULL)
  18. {
  19. LOG_E("thread:%s exit:%d!", self->name, status);
  20. rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL);
  21. }
  22. }
  23. #ifdef RT_USING_MSH
  24. int system(const char *command)
  25. {
  26. extern int msh_exec(char *cmd, rt_size_t length);
  27. int ret = -RT_ENOMEM;
  28. char *cmd = rt_strdup(command);
  29. if (cmd)
  30. {
  31. ret = msh_exec(cmd, rt_strlen(cmd));
  32. rt_free(cmd);
  33. }
  34. return ret;
  35. }
  36. RTM_EXPORT(system);
  37. #endif