stdlib.c 798 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. if (command)
  28. {
  29. msh_exec((char *)command, rt_strlen(command));
  30. }
  31. return 0;
  32. }
  33. RTM_EXPORT(system);
  34. #endif /* RT_USING_MSH */