Home | History | Annotate | Line # | Download | only in gen
 $NetBSD: posix_spawn_file_actions_addchdir.3,v 1.3 2021/11/15 16:00:25 kre Exp $

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard is
the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html.

.Dd July 8, 2020 .Dt POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR 3 .Os .Sh NAME .Nm posix_spawn_file_actions_addchdir , .Nm posix_spawn_file_actions_addfchdir .Nd add chdir or fchdir action to spawn file actions object .Sh LIBRARY .Lb libc .Sh SYNOPSIS n spawn.h .Ft int .Fn posix_spawn_file_actions_addchdir "posix_spawn_file_actions_t *restrict file_actions" "const char *restrict path" .Ft int .Fn posix_spawn_file_actions_addfchdir "posix_spawn_file_actions_t * file_actions" "int fildes" .Sh DESCRIPTION The .Fn posix_spawn_file_actions_addchdir function adds a chdir action to the object referenced by .Fa file_actions that causes the working directory to be set to .Fa path (as if d -literal -offset indent chdir(path) .Ed

p had been called) for a new process spawned using this file actions object. A relative .Fa path is interpreted relative to the working directory determined by any prior actions. The string pointed to by .Fa path is copied by the .Fn posix_spawn_file_actions_addchdir function.

p The .Fn posix_spawn_file_actions_addfchdir function adds a fchdir action to the object referenced by .Fa file_actions that causes the working directory to be set to the directory referenced by .Fa fildes (as if d -literal -offset indent fchdir(fildes) .Ed

p had been called) for a new process spawned using this file actions object. The last paragraph of APPLICATION USAGE

p File actions are performed in the new process created by .Fn posix_spawn or .Fn posix_spawnp in the same order that they were added to the file actions object. Thus the execution of an .Dq open action that was created by a call to .Fn posix_spawn_file_actions_addopen that specifies a relative path will be affected by the execution of a chdir or fchdir action that was created by a previous call to .Fn posix_spawn_file_actions_addchdir or .Fn posix_spawn_file_actions_addfchdir . Likewise, a relative path passed to .Fn posix_spawn will be affected by the last chdir or fchdir action in the file action list. .Sh RETURN VALUES Upon successful completion, these function return zero; otherwise, an error number is returned to indicate the error. .Sh ERRORS The .Fn posix_spawn_file_actions_addfchdir function fails if: l -tag -width Er t Bq Er EBADF The value specified by .Fa fildes is negative. .El

p Both functions may fail with: l -tag -width Er t Bq Er EINVAL The value specified by .Fa file_actions is invalid. t Bq Er ENOMEM Insufficient memory exists to add the spawn file actions object. .El

p It is not an error for the .Fa path or .Fa fildes argument passed to these functions to specify a pathname or file descriptor for which the specified operation could not be performed at the time of the call. Any such error will be detected when the associated file actions object is later used during a .Fn posix_spawn or .Fn posix_spawnp operation. .Sh SEE ALSO .Xr chdir 2 , .Xr fchdir 2 , .Xr posix_spawn 3 , .Xr posix_spawn_file_actions_destroy 3 , .Xr posix_spawn_file_actions_init 3 , .Xr posix_spawnp 3 .Sh STANDARDS The .Fn posix_spawn_file_actions_addchdir and .Fn posix_spawn_file_actions_addfchdir functions conform to .St -p1003.1-2001 . .Sh HISTORY The POSIX implementation of .Fn posix_spawn_file_actions_addchdir and .Fn posix_spawn_file_actions_addfchdir is derived from SOLARIS kernel's .Fn posix_spawn_file_actions_addchdir_np . .Sh AUTHORS .An Piyush Sachdeva