From 58293abb8e896bb04f3a76bf8b48206debe68f26 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 12 May 2021 11:47:42 +0800 Subject: [PATCH] Follow up task_spawn change from kernel side Signed-off-by: Xiang Xiao --- builtin/exec_builtin.c | 3 ++- system/popen/popen.c | 12 ++++++++---- system/system/system.c | 8 ++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/builtin/exec_builtin.c b/builtin/exec_builtin.c index 7f7b34c76..1fc66c526 100644 --- a/builtin/exec_builtin.c +++ b/builtin/exec_builtin.c @@ -192,9 +192,10 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv, { /* Start the built-in */ - ret = task_spawn(&pid, builtin->name, builtin->main, &file_actions, + pid = task_spawn(builtin->name, builtin->main, &file_actions, &attr, (argv) ? &argv[1] : (FAR char * const *)NULL, (FAR char * const *)NULL); + ret = pid < 0 ? -pid : 0; } if (ret != 0) diff --git a/system/popen/popen.c b/system/popen/popen.c index 7f2d79743..d9f77572c 100644 --- a/system/popen/popen.c +++ b/system/popen/popen.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/popen/popen/popen.c + * apps/system/popen/popen.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -253,13 +253,17 @@ FILE *popen(FAR const char *command, FAR const char *mode) &file_actions, &attr, argv, (FAR char * const *)NULL); #else - errcode = task_spawn(&container->shell, "popen", nsh_system, &file_actions, - &attr, argv, (FAR char * const *)NULL); + container->shell = task_spawn("popen", nsh_system, &file_actions, + &attr, argv, (FAR char * const *)NULL); + if (container->shell < 0) + { + errcode = -container->shell; + } #endif if (errcode != 0) { - serr("ERROR: Spawn failed: %d\n", result); + serr("ERROR: Spawn failed: %d\n", errcode); goto errout_with_actions; } diff --git a/system/system/system.c b/system/system/system.c index 82423034e..b48e91d65 100644 --- a/system/system/system.c +++ b/system/system/system.c @@ -136,8 +136,12 @@ int system(FAR const char *cmd) errcode = posix_spawn(&pid, CONFIG_SYSTEM_SYSTEM_SHPATH, NULL, &attr, argv, (FAR char * const *)NULL); #else - errcode = task_spawn(&pid, "system", nsh_system, NULL, &attr, - argv, (FAR char * const *)NULL); + pid = task_spawn("system", nsh_system, NULL, &attr, + argv, (FAR char * const *)NULL); + if (pid < 0) + { + errcode = -pid; + } #endif /* Release the attributes and check for an error from the spawn operation */