2019-08-23 21:20:52 +02:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* libs/libc/spawn/lib_task_spawn.c
|
2019-08-23 21:20:52 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2019-08-23 21:20:52 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-08-23 21:20:52 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2019-08-23 21:20:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <spawn.h>
|
|
|
|
#include <nuttx/spawn.h>
|
|
|
|
|
2020-05-02 12:36:48 +02:00
|
|
|
#if defined(CONFIG_LIB_SYSCALL) && !defined(CONFIG_BUILD_KERNEL)
|
2019-08-23 21:20:52 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: task_spawn
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function marshals task_spwan() parameters and invokes the
|
|
|
|
* nx_task_spawn() system call.
|
|
|
|
*
|
|
|
|
* task_spawn() and posix_spawn() are NuttX OS interfaces. In PROTECTED
|
|
|
|
* and KERNEL build modes, then can be reached from applications only via
|
|
|
|
* a system call. Currently, the number of parameters in a system call
|
|
|
|
* is limited to six; these spawn function have seven parameters. Rather
|
|
|
|
* than extend the maximum number of parameters across all architectures,
|
|
|
|
* I opted instead to marshal the seven parameters into a structure.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* file_actions - The address of the posix_spawn_file_actions_t to be
|
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, these functions return 0; on failure they return an error
|
|
|
|
* number from <errno.h>.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
|
|
|
|
FAR const posix_spawn_file_actions_t *file_actions,
|
|
|
|
FAR const posix_spawnattr_t *attr,
|
2020-05-06 11:24:42 +02:00
|
|
|
FAR char * const argv[], FAR char * const envp[])
|
2019-08-23 21:20:52 +02:00
|
|
|
{
|
|
|
|
struct spawn_syscall_parms_s parms;
|
|
|
|
|
|
|
|
parms.pid = pid;
|
|
|
|
parms.name = name;
|
|
|
|
parms.entry = entry;
|
|
|
|
parms.file_actions = file_actions;
|
|
|
|
parms.attr = attr;
|
|
|
|
parms.argv = (FAR char * const *)argv;
|
|
|
|
parms.envp = (FAR char * const *)envp;
|
|
|
|
|
|
|
|
return nx_task_spawn(&parms);
|
|
|
|
}
|
|
|
|
|
2020-05-02 12:36:48 +02:00
|
|
|
#endif /* CONFIG_LIB_SYSCALL && !CONFIG_BUILD_KERNEL */
|