From c80688126a013c53334464799e28fcf2e4f4fb8c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 27 Sep 2021 22:20:21 -0400 Subject: [libc] 优化system 支持gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/stdlib.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'components/libc/compilers/common/stdlib.c') diff --git a/components/libc/compilers/common/stdlib.c b/components/libc/compilers/common/stdlib.c index 16a13afb83..6cc0b9fdac 100644 --- a/components/libc/compilers/common/stdlib.c +++ b/components/libc/compilers/common/stdlib.c @@ -25,11 +25,21 @@ void __rt_libc_exit(int status) } } -int __rt_libc_system(const char *string) -{ #ifdef RT_USING_MSH +int system(const char *command) +{ extern int msh_exec(char *cmd, rt_size_t length); - msh_exec((char*)string, rt_strlen(string)); -#endif - return 0; + + int ret = -RT_ENOMEM; + char *cmd = rt_strdup(command); + + if (cmd) + { + ret = msh_exec(cmd, rt_strlen(cmd)); + rt_free(cmd); + } + + return ret; } +RTM_EXPORT(system); +#endif -- cgit v1.3.1