Index: head/include/paths.h =================================================================== --- head/include/paths.h (revision 293203) +++ head/include/paths.h (revision 293204) @@ -1,144 +1,144 @@ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * 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. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. * * @(#)paths.h 8.1 (Berkeley) 6/2/93 * $FreeBSD$ */ #ifndef _PATHS_H_ #define _PATHS_H_ #include /* Default search path. */ -#define _PATH_DEFPATH "/usr/bin:/bin" +#define _PATH_DEFPATH "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" /* All standard utilities path. */ #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" /* Locate system binaries. */ #define _PATH_SYSPATH "/sbin:/usr/sbin" #define _PATH_BSHELL "/bin/sh" #define _PATH_CAPABILITY "/etc/capability" #define _PATH_CAPABILITY_DB "/etc/capability.db" #define _PATH_CONSOLE "/dev/console" #define _PATH_CP "/bin/cp" #define _PATH_CSHELL "/bin/csh" #define _PATH_CSMAPPER "/usr/share/i18n/csmapper" #define _PATH_DEFTAPE "/dev/sa0" #define _PATH_DEVGPIOC "/dev/gpioc" #define _PATH_DEVNULL "/dev/null" #define _PATH_DEVZERO "/dev/zero" #define _PATH_DRUM "/dev/drum" #define _PATH_ESDB "/usr/share/i18n/esdb" #define _PATH_ETC "/etc" #define _PATH_FTPUSERS "/etc/ftpusers" #define _PATH_FWMEM "/dev/fwmem" #define _PATH_GBDE "/sbin/gbde" #define _PATH_GELI "/sbin/geli" #define _PATH_HALT "/sbin/halt" #ifdef COMPAT_32BIT #define _PATH_I18NMODULE "/usr/lib32/i18n" #else #define _PATH_I18NMODULE "/usr/lib/i18n" #endif #define _PATH_IFCONFIG "/sbin/ifconfig" #define _PATH_KMEM "/dev/kmem" #define _PATH_LIBMAP_CONF "/etc/libmap.conf" #define _PATH_LOCALE "/usr/share/locale" #define _PATH_LOGIN "/usr/bin/login" #define _PATH_MAILDIR "/var/mail" #define _PATH_MAN "/usr/share/man" #define _PATH_MDCONFIG "/sbin/mdconfig" #define _PATH_MEM "/dev/mem" #define _PATH_MKSNAP_FFS "/sbin/mksnap_ffs" #define _PATH_MOUNT "/sbin/mount" #define _PATH_NEWFS "/sbin/newfs" #define _PATH_NOLOGIN "/var/run/nologin" #define _PATH_RCP "/bin/rcp" #define _PATH_REBOOT "/sbin/reboot" #define _PATH_RLOGIN "/usr/bin/rlogin" #define _PATH_RM "/bin/rm" #define _PATH_RSH "/usr/bin/rsh" #define _PATH_SENDMAIL "/usr/sbin/sendmail" #define _PATH_SHELLS "/etc/shells" #define _PATH_TTY "/dev/tty" #define _PATH_UNIX "don't use _PATH_UNIX" #define _PATH_UFSSUSPEND "/dev/ufssuspend" #define _PATH_VI "/usr/bin/vi" #define _PATH_WALL "/usr/bin/wall" /* Provide trailing slash, since mostly used for building pathnames. */ #define _PATH_DEV "/dev/" #define _PATH_TMP "/tmp/" #define _PATH_VARDB "/var/db/" #define _PATH_VARRUN "/var/run/" #define _PATH_VARTMP "/var/tmp/" #define _PATH_YP "/var/yp/" #define _PATH_UUCPLOCK "/var/spool/lock/" /* How to get the correct name of the kernel. */ __BEGIN_DECLS const char *getbootfile(void); __END_DECLS #ifdef RESCUE #undef _PATH_DEFPATH -#define _PATH_DEFPATH "/rescue:/usr/bin:/bin" +#define _PATH_DEFPATH "/rescue:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" #undef _PATH_STDPATH #define _PATH_STDPATH "/rescue:/usr/bin:/bin:/usr/sbin:/sbin" #undef _PATH_SYSPATH #define _PATH_SYSPATH "/rescue:/sbin:/usr/sbin" #undef _PATH_BSHELL #define _PATH_BSHELL "/rescue/sh" #undef _PATH_CP #define _PATH_CP "/rescue/cp" #undef _PATH_CSHELL #define _PATH_CSHELL "/rescue/csh" #undef _PATH_HALT #define _PATH_HALT "/rescue/halt" #undef _PATH_IFCONFIG #define _PATH_IFCONFIG "/rescue/ifconfig" #undef _PATH_MDCONFIG #define _PATH_MDCONFIG "/rescue/mdconfig" #undef _PATH_MOUNT #define _PATH_MOUNT "/rescue/mount" #undef _PATH_NEWFS #define _PATH_NEWFS "/rescue/newfs" #undef _PATH_RCP #define _PATH_RCP "/rescue/rcp" #undef _PATH_REBOOT #define _PATH_REBOOT "/rescue/reboot" #undef _PATH_RM #define _PATH_RM "/rescue/rm" #undef _PATH_VI #define _PATH_VI "/rescue/vi" #undef _PATH_WALL #define _PATH_WALL "/rescue/wall" #endif /* RESCUE */ #endif /* !_PATHS_H_ */ Index: head/lib/libc/gen/exec.3 =================================================================== --- head/lib/libc/gen/exec.3 (revision 293203) +++ head/lib/libc/gen/exec.3 (revision 293204) @@ -1,321 +1,321 @@ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" 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. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. .\" .\" @(#)exec.3 8.3 (Berkeley) 1/24/94 .\" $FreeBSD$ .\" -.Dd December 12, 2015 +.Dd January 5, 2016 .Dt EXEC 3 .Os .Sh NAME .Nm execl , .Nm execlp , .Nm execle , .Nm exect , .Nm execv , .Nm execvp , .Nm execvP .Nd execute a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Vt extern char **environ ; .Ft int .Fn execl "const char *path" "const char *arg" ... /* "(char *)0" */ .Ft int .Fn execlp "const char *file" "const char *arg" ... /* "(char *)0" */ .Ft int .Fo execle .Fa "const char *path" "const char *arg" ... .Fa /* .Bk -words .Fa "(char *)0" "char *const envp[]" */ .Ek .Fc .Ft int .Fn exect "const char *path" "char *const argv[]" "char *const envp[]" .Ft int .Fn execv "const char *path" "char *const argv[]" .Ft int .Fn execvp "const char *file" "char *const argv[]" .Ft int .Fn execvP "const char *file" "const char *search_path" "char *const argv[]" .Sh DESCRIPTION The .Nm exec family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for the function .Xr execve 2 . (See the manual page for .Xr execve 2 for detailed information about the replacement of the current process.) .Pp The initial argument for these functions is the pathname of a file which is to be executed. .Pp The .Fa "const char *arg" and subsequent ellipses in the .Fn execl , .Fn execlp , and .Fn execle functions can be thought of as .Em arg0 , .Em arg1 , \&..., .Em argn . Together they describe a list of one or more pointers to null-terminated strings that represent the argument list available to the executed program. The first argument, by convention, should point to the file name associated with the file being executed. The list of arguments .Em must be terminated by a .Dv NULL pointer. .Pp The .Fn exect , .Fn execv , .Fn execvp , and .Fn execvP functions provide an array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, should point to the file name associated with the file being executed. The array of pointers .Sy must be terminated by a .Dv NULL pointer. .Pp The .Fn execle and .Fn exect functions also specify the environment of the executed process by following the .Dv NULL pointer that terminates the list of arguments in the argument list or the pointer to the argv array with an additional argument. This additional argument is an array of pointers to null-terminated strings and .Em must be terminated by a .Dv NULL pointer. The other functions take the environment for the new process image from the external variable .Va environ in the current process. .Pp Some of these functions have special semantics. .Pp The functions .Fn execlp , .Fn execvp , and .Fn execvP will duplicate the actions of the shell in searching for an executable file if the specified file name does not contain a slash .Dq Li / character. For .Fn execlp and .Fn execvp , search path is the path specified in the environment by .Dq Ev PATH variable. If this variable is not specified, the default path is set according to the .Dv _PATH_DEFPATH definition in .In paths.h , which is set to -.Dq Ev /usr/bin:/bin . +.Dq Ev /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin . For .Fn execvP , the search path is specified as an argument to the function. In addition, certain errors are treated specially. .Pp If an error is ambiguous (for simplicity, we shall consider all errors except .Er ENOEXEC as being ambiguous here, although only the critical error .Er EACCES is really ambiguous), then these functions will act as if they stat the file to determine whether the file exists and has suitable execute permissions. If it does, they will return immediately with the global variable .Va errno restored to the value set by .Fn execve . Otherwise, the search will be continued. If the search completes without performing a successful .Fn execve or terminating due to an error, these functions will return with the global variable .Va errno set to .Er EACCES or .Er ENOENT according to whether at least one file with suitable execute permissions was found. .Pp If the header of a file is not recognized (the attempted .Fn execve returned .Er ENOEXEC ) , these functions will execute the shell with the path of the file as its first argument. (If this attempt fails, no further searching is done.) .Pp The function .Fn exect executes a file with the program tracing facilities enabled (see .Xr ptrace 2 ) . .Sh RETURN VALUES If any of the .Fn exec functions returns, an error will have occurred. The return value is \-1, and the global variable .Va errno will be set to indicate the error. .Sh FILES .Bl -tag -width /bin/sh -compact .It Pa /bin/sh The shell. .El .Sh COMPATIBILITY Historically, the default path for the .Fn execlp and .Fn execvp functions was .Dq Pa :/bin:/usr/bin . This was changed to remove the current directory to enhance system security. .Pp The behavior of .Fn execlp and .Fn execvp when errors occur while attempting to execute the file is not quite historic practice, and has not traditionally been documented and is not specified by the .Tn POSIX standard. .Pp Traditionally, the functions .Fn execlp and .Fn execvp ignored all errors except for the ones described above and .Er ETXTBSY , upon which they retried after sleeping for several seconds, and .Er ENOMEM and .Er E2BIG , upon which they returned. They now return for .Er ETXTBSY , and determine existence and executability more carefully. In particular, .Er EACCES for inaccessible directories in the path prefix is no longer confused with .Er EACCES for files with unsuitable execute permissions. In .Bx 4.4 , they returned upon all errors except .Er EACCES , .Er ENOENT , .Er ENOEXEC and .Er ETXTBSY . This was inferior to the traditional error handling, since it breaks the ignoring of errors for path prefixes and only improves the handling of the unusual ambiguous error .Er EFAULT and the unusual error .Er EIO . The behaviour was changed to match the behaviour of .Xr sh 1 . .Sh ERRORS The .Fn execl , .Fn execle , .Fn execlp , .Fn execvp and .Fn execvP functions may fail and set .Va errno for any of the errors specified for the library functions .Xr execve 2 and .Xr malloc 3 . .Pp The .Fn exect and .Fn execv functions may fail and set .Va errno for any of the errors specified for the library function .Xr execve 2 . .Sh SEE ALSO .Xr sh 1 , .Xr execve 2 , .Xr fork 2 , .Xr ktrace 2 , .Xr ptrace 2 , .Xr environ 7 .Sh STANDARDS The .Fn execl , .Fn execv , .Fn execle , .Fn execlp and .Fn execvp functions conform to .St -p1003.1-88 . The .Fn execvP function first appeared in .Fx 5.2 . Index: head/lib/libc/gen/posix_spawn.3 =================================================================== --- head/lib/libc/gen/posix_spawn.3 (revision 293203) +++ head/lib/libc/gen/posix_spawn.3 (revision 293204) @@ -1,460 +1,460 @@ .\" Copyright (c) 2008 Ed Schouten .\" All rights reserved. .\" .\" 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. .\" .\" $FreeBSD$ .\" -.Dd June 17, 2011 +.Dd January 5, 2016 .Dt POSIX_SPAWN 3 .Os .Sh NAME .Nm posix_spawn , .Nm posix_spawnp .Nd "spawn a process" .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In spawn.h .Ft int .Fn posix_spawn "pid_t *restrict pid" "const char *restrict path" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]" .Ft int .Fn posix_spawnp "pid_t *restrict pid" "const char *restrict file" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]" .Sh DESCRIPTION The .Fn posix_spawn and .Fn posix_spawnp functions create a new process (child process) from the specified process image. The new process image is constructed from a regular executable file called the new process image file. .Pp When a C program is executed as the result of this call, it is entered as a C-language function call as follows: .Bd -literal -offset indent int main(int argc, char *argv[]); .Ed .Pp where .Fa argc is the argument count and .Fa argv is an array of character pointers to the arguments themselves. In addition, the variable: .Bd -literal -offset indent extern char **environ; .Ed .Pp points to an array of character pointers to the environment strings. .Pp The argument .Fa argv is an array of character pointers to null-terminated strings. The last member of this array is a null pointer and is not counted in .Fa argc . These strings constitute the argument list available to the new process image. The value in .Fa argv Ns [0] should point to a filename that is associated with the process image being started by the .Fn posix_spawn or .Fn posix_spawnp function. .Pp The argument .Fa envp is an array of character pointers to null-terminated strings. These strings constitute the environment for the new process image. The environment array is terminated by a null pointer. .Pp The .Fa path argument to .Fn posix_spawn is a pathname that identifies the new process image file to execute. .Pp The .Fa file parameter to .Fn posix_spawnp is used to construct a pathname that identifies the new process image file. If the file parameter contains a slash character, the file parameter is used as the pathname for the new process image file. Otherwise, the path prefix for this file is obtained by a search of the directories passed as the environment variable .Dq Ev PATH . If this variable is not specified, the default path is set according to the .Dv _PATH_DEFPATH definition in .In paths.h , which is set to -.Dq Ev /usr/bin:/bin . +.Dq Ev /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin . .Pp If .Fa file_actions is a null pointer, then file descriptors open in the calling process remain open in the child process, except for those whose close-on-exec flag .Dv FD_CLOEXEC is set (see .Fn fcntl ) . For those file descriptors that remain open, all attributes of the corresponding open file descriptions, including file locks (see .Fn fcntl ) , remain unchanged. .Pp If .Fa file_actions is not NULL, then the file descriptors open in the child process are those open in the calling process as modified by the spawn file actions object pointed to by .Fa file_actions and the .Dv FD_CLOEXEC flag of each remaining open file descriptor after the spawn file actions have been processed. The effective order of processing the spawn file actions are: .Bl -enum .It The set of open file descriptors for the child process initially are the same set as is open for the calling process. All attributes of the corresponding open file descriptions, including file locks (see .Fn fcntl ) , remain unchanged. .It The signal mask, signal default actions, and the effective user and group IDs for the child process are changed as specified in the attributes object referenced by .Fa attrp . .It The file actions specified by the spawn file actions object are performed in the order in which they were added to the spawn file actions object. .It Any file descriptor that has its .Dv FD_CLOEXEC flag set (see .Fn fcntl ) is closed. .El .Pp The .Vt posix_spawnattr_t spawn attributes object type is defined in .In spawn.h . It contains the attributes defined below. .Pp If the .Dv POSIX_SPAWN_SETPGROUP flag is set in the spawn-flags attribute of the object referenced by .Fa attrp , and the spawn-pgroup attribute of the same object is non-zero, then the child's process group is as specified in the spawn-pgroup attribute of the object referenced by .Fa attrp . .Pp As a special case, if the .Dv POSIX_SPAWN_SETPGROUP flag is set in the spawn-flags attribute of the object referenced by .Fa attrp , and the spawn-pgroup attribute of the same object is set to zero, then the child is in a new process group with a process group ID equal to its process ID. .Pp If the .Dv POSIX_SPAWN_SETPGROUP flag is not set in the spawn-flags attribute of the object referenced by .Fa attrp , the new child process inherits the parent's process group. .Pp If the .Dv POSIX_SPAWN_SETSCHEDPARAM flag is set in the spawn-flags attribute of the object referenced by .Fa attrp , but .Dv POSIX_SPAWN_SETSCHEDULER is not set, the new process image initially has the scheduling policy of the calling process with the scheduling parameters specified in the spawn-schedparam attribute of the object referenced by .Fa attrp . .Pp If the .Dv POSIX_SPAWN_SETSCHEDULER flag is set in the spawn-flags attribute of the object referenced by .Fa attrp (regardless of the setting of the .Dv POSIX_SPAWN_SETSCHEDPARAM flag), the new process image initially has the scheduling policy specified in the spawn-schedpolicy attribute of the object referenced by .Fa attrp and the scheduling parameters specified in the spawn-schedparam attribute of the same object. .Pp The .Dv POSIX_SPAWN_RESETIDS flag in the spawn-flags attribute of the object referenced by .Fa attrp governs the effective user ID of the child process. If this flag is not set, the child process inherits the parent process' effective user ID. If this flag is set, the child process' effective user ID is reset to the parent's real user ID. In either case, if the set-user-ID mode bit of the new process image file is set, the effective user ID of the child process becomes that file's owner ID before the new process image begins execution. .Pp The .Dv POSIX_SPAWN_RESETIDS flag in the spawn-flags attribute of the object referenced by .Fa attrp also governs the effective group ID of the child process. If this flag is not set, the child process inherits the parent process' effective group ID. If this flag is set, the child process' effective group ID is reset to the parent's real group ID. In either case, if the set-group-ID mode bit of the new process image file is set, the effective group ID of the child process becomes that file's group ID before the new process image begins execution. .Pp If the .Dv POSIX_SPAWN_SETSIGMASK flag is set in the spawn-flags attribute of the object referenced by .Fa attrp , the child process initially has the signal mask specified in the spawn-sigmask attribute of the object referenced by .Fa attrp . .Pp If the .Dv POSIX_SPAWN_SETSIGDEF flag is set in the spawn-flags attribute of the object referenced by .Fa attrp , the signals specified in the spawn-sigdefault attribute of the same object is set to their default actions in the child process. Signals set to the default action in the parent process is set to the default action in the child process. .Pp Signals set to be caught by the calling process is set to the default action in the child process. .Pp Signals set to be ignored by the calling process image is set to be ignored by the child process, unless otherwise specified by the .Dv POSIX_SPAWN_SETSIGDEF flag being set in the spawn-flags attribute of the object referenced by .Fa attrp and the signals being indicated in the spawn-sigdefault attribute of the object referenced by .Fa attrp . .Pp If the value of the .Fa attrp pointer is NULL, then the default values are used. .Pp All process attributes, other than those influenced by the attributes set in the object referenced by .Fa attrp as specified above or by the file descriptor manipulations specified in .Fa file_actions , appear in the new process image as though .Fn vfork had been called to create a child process and then .Fn execve had been called by the child process to execute the new process image. .Pp The implementation uses vfork(), thus the fork handlers are not run when .Fn posix_spawn or .Fn posix_spawnp is called. .Sh RETURN VALUES Upon successful completion, .Fn posix_spawn and .Fn posix_spawnp return the process ID of the child process to the parent process, in the variable pointed to by a non-NULL .Fa pid argument, and return zero as the function return value. Otherwise, no child process is created, no value is stored into the variable pointed to by .Fa pid , and an error number is returned as the function return value to indicate the error. If the .Fa pid argument is a null pointer, the process ID of the child is not returned to the caller. .Sh ERRORS .Bl -enum .It If .Fn posix_spawn and .Fn posix_spawnp fail for any of the reasons that would cause .Fn vfork or one of the .Nm exec to fail, an error value is returned as described by .Fn vfork and .Nm exec , respectively (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). .It If .Nm POSIX_SPAWN_SETPGROUP is set in the spawn-flags attribute of the object referenced by attrp, and .Fn posix_spawn or .Fn posix_spawnp fails while changing the child's process group, an error value is returned as described by .Fn setpgid (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). .It If .Nm POSIX_SPAWN_SETSCHEDPARAM is set and .Nm POSIX_SPAWN_SETSCHEDULER is not set in the spawn-flags attribute of the object referenced by attrp, then if .Fn posix_spawn or .Fn posix_spawnp fails for any of the reasons that would cause .Fn sched_setparam to fail, an error value is returned as described by .Fn sched_setparam (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). .It If .Nm POSIX_SPAWN_SETSCHEDULER is set in the spawn-flags attribute of the object referenced by attrp, and if .Fn posix_spawn or .Fn posix_spawnp fails for any of the reasons that would cause .Fn sched_setscheduler to fail, an error value is returned as described by .Fn sched_setscheduler (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). .It If the .Fa file_actions argument is not NULL, and specifies any dup2 or open actions to be performed, and if .Fn posix_spawn or .Fn posix_spawnp fails for any of the reasons that would cause .Fn dup2 or .Fn open to fail, an error value is returned as described by .Fn dup2 and .Fn open , respectively (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). An open file action may, by itself, result in any of the errors described by .Fn dup2 , in addition to those described by .Fn open . This implementation ignores any errors from .Fn close , including trying to close a descriptor that is not open. .El .Sh SEE ALSO .Xr close 2 , .Xr dup2 2 , .Xr execve 2 , .Xr fcntl 2 , .Xr open 2 , .Xr sched_setparam 2 , .Xr sched_setscheduler 2 , .Xr setpgid 2 , .Xr vfork 2 , .Xr posix_spawn_file_actions_addclose 3 , .Xr posix_spawn_file_actions_adddup2 3 , .Xr posix_spawn_file_actions_addopen 3 , .Xr posix_spawn_file_actions_destroy 3 , .Xr posix_spawn_file_actions_init 3 , .Xr posix_spawnattr_destroy 3 , .Xr posix_spawnattr_getflags 3 , .Xr posix_spawnattr_getpgroup 3 , .Xr posix_spawnattr_getschedparam 3 , .Xr posix_spawnattr_getschedpolicy 3 , .Xr posix_spawnattr_getsigdefault 3 , .Xr posix_spawnattr_getsigmask 3 , .Xr posix_spawnattr_init 3 , .Xr posix_spawnattr_setflags 3 , .Xr posix_spawnattr_setpgroup 3 , .Xr posix_spawnattr_setschedparam 3 , .Xr posix_spawnattr_setschedpolicy 3 , .Xr posix_spawnattr_setsigdefault 3 , .Xr posix_spawnattr_setsigmask 3 .Sh STANDARDS The .Fn posix_spawn and .Fn posix_spawnp functions conform to .St -p1003.1-2001 , except that they ignore all errors from .Fn close . A future update of the Standard is expected to require that these functions not fail because a file descriptor to be closed (via .Fn posix_spawn_file_actions_addclose ) is not open. .Sh HISTORY The .Fn posix_spawn and .Fn posix_spawnp functions first appeared in .Fx 8.0 . .Sh AUTHORS .An \&Ed Schouten Aq Mt ed@FreeBSD.org Index: head/usr.sbin/cron/crontab/crontab.5 =================================================================== --- head/usr.sbin/cron/crontab/crontab.5 (revision 293203) +++ head/usr.sbin/cron/crontab/crontab.5 (revision 293204) @@ -1,323 +1,323 @@ .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie .\" * All rights reserved .\" * .\" * Distribute freely, except: don't remove my name from the source or .\" * documentation (don't take credit for my work), mark your changes (don't .\" * get me blamed for your possible bugs), don't alter or remove this .\" * notice. May be sold if buildable source is provided to buyer. No .\" * warrantee of any kind, express or implied, is included with this .\" * software; use at your own risk, responsibility for damages (if any) to .\" * anyone resulting from the use of this software rests entirely with the .\" * user. .\" * .\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and .\" * I'll try to keep a version up to date. I can be reached as follows: .\" * Paul Vixie uunet!decwrl!vixie!paul .\" */ .\" .\" $FreeBSD$ .\" -.Dd April 28, 2012 +.Dd January 5, 2016 .Dt CRONTAB 5 .Os .Sh NAME .Nm crontab .Nd tables for driving cron .Sh DESCRIPTION A .Nm file contains instructions to the .Xr cron 8 daemon of the general form: ``run this command at this time on this date''. Each user has their own crontab, and commands in any given crontab will be executed as the user who owns the crontab. Uucp and News will usually have their own crontabs, eliminating the need for explicitly running .Xr su 1 as part of a cron command. .Pp Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. Note that comments are not allowed on the same line as cron commands, since they will be taken to be part of the command. Similarly, comments are not allowed on the same line as environment variable settings. .Pp An active line in a crontab will be either an environment setting or a cron command. An environment setting is of the form, .Bd -literal name = value .Ed .Pp where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in .Em value will be part of the value assigned to .Em name . The .Em value string may be placed in quotes (single or double, but matching) to preserve leading or trailing blanks. The .Em name string may also be placed in quote (single or double, but matching) to preserve leading, trailing or inner blanks. .Pp Several environment variables are set up automatically by the .Xr cron 8 daemon. .Ev SHELL is set to .Pa /bin/sh , .Ev PATH is set to -.Pa /usr/bin:/bin , +.Pa /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin , and .Ev LOGNAME and .Ev HOME are set from the .Pa /etc/passwd line of the crontab's owner. .Ev HOME , .Ev PATH and .Ev SHELL may be overridden by settings in the crontab; .Ev LOGNAME may not. .Pp (Another note: the .Ev LOGNAME variable is sometimes called .Ev USER on .Bx systems... On these systems, .Ev USER will be set also). .Pp In addition to .Ev LOGNAME , .Ev HOME , .Ev PATH , and .Ev SHELL , .Xr cron 8 will look at .Ev MAILTO if it has any reason to send mail as a result of running commands in ``this'' crontab. If .Ev MAILTO is defined (and non-empty), mail is sent to the user so named. .Ev MAILTO may also be used to direct mail to multiple recipients by separating recipient users with a comma. If .Ev MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab. This option is useful if you decide on .Pa /bin/mail instead of .Pa /usr/lib/sendmail as your mailer when you install cron -- .Pa /bin/mail does not do aliasing, and UUCP usually does not read its mail. .Pp The format of a cron command is very much the V7 standard, with a number of upward-compatible extensions. Each line has five time and date fields, followed by a user name (with optional ``:'' and ``/'' suffixes) if this is the system crontab file, followed by a command. Commands are executed by .Xr cron 8 when the minute, hour, and month of year fields match the current time, .Em and when at least one of the two day fields (day of month, or day of week) matches the current time (see ``Note'' below). .Xr cron 8 examines cron entries once every minute. The time and date fields are: .Bd -literal -offset indent field allowed values ----- -------------- minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sun, or use names) .Ed .Pp A field may be an asterisk (*), which always stands for ``first\-last''. .Pp Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11. .Pp Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''. .Pp Step values can be used in conjunction with ranges. Following a range with ``/'' specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to say ``every two hours'', just use ``*/2''. .Pp Names can also be used for the ``month'' and ``day of week'' fields. Use the first three letters of the particular day or month (case does not matter). Ranges or lists of names are not allowed. .Pp The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by .Pa /bin/sh or by the shell specified in the .Ev SHELL variable of the cronfile. Percent-signs (%) in the command, unless escaped with backslash (\\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. .Pp Note: The day of a command's execution can be specified by two fields \(em day of month, and day of week. If both fields are restricted (ie, are not *), the command will be run when .Em either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday. .Pp Instead of the first five fields, one of eight special strings may appear: .Bd -literal -offset indent string meaning ------ ------- @reboot Run once, at startup of cron. @yearly Run once a year, "0 0 1 1 *". @annually (same as @yearly) @monthly Run once a month, "0 0 1 * *". @weekly Run once a week, "0 0 * * 0". @daily Run once a day, "0 0 * * *". @midnight (same as @daily) @hourly Run once an hour, "0 * * * *". @every_minute Run once a minute, "*/1 * * * *". @every_second Run once a second. .Ed .Sh EXAMPLE CRON FILE .Bd -literal # use /bin/sh to run commands, overriding the default set by cron SHELL=/bin/sh # mail any output to `paul', no matter whose crontab this is MAILTO=paul # # run five minutes after midnight, every day 5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 # run at 2:15pm on the first of every month -- output mailed to paul 15 14 1 * * $HOME/bin/monthly # run at 10 pm on weekdays, annoy Joe 0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?% 23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday" 5 4 * * sun echo "run at 5 after 4 every sunday" .Ed .Sh SEE ALSO .Xr crontab 1 , .Xr cron 8 .Sh EXTENSIONS When specifying day of week, both day 0 and day 7 will be considered Sunday. .Bx and .Tn ATT seem to disagree about this. .Pp Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would be rejected by .Tn ATT or .Bx cron -- they want to see "1-3" or "7,8,9" ONLY. .Pp Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9". .Pp Names of months or days of the week can be specified by name. .Pp Environment variables can be set in the crontab. In .Bx or .Tn ATT , the environment handed to child processes is basically the one from .Pa /etc/rc . .Pp Command output is mailed to the crontab owner .No ( Bx cannot do this), can be mailed to a person other than the crontab owner (SysV cannot do this), or the feature can be turned off and no mail will be sent at all (SysV cannot do this either). .Pp All of the .Sq @ commands that can appear in place of the first five fields are extensions. .Sh AUTHORS .An Paul Vixie Aq Mt paul@vix.com .Sh BUGS If you are in one of the 70-odd countries that observe Daylight Savings Time, jobs scheduled during the rollback or advance may be affected if .Xr cron 8 is not started with the .Fl s flag. In general, it is not a good idea to schedule jobs during this period if .Xr cron 8 is not started with the .Fl s flag, which is enabled by default. See .Xr cron 8 for more details. .Pp For US timezones (except parts of AZ and HI) the time shift occurs at 2AM local time. For others, the output of the .Xr zdump 8 program's verbose .Fl ( v ) option can be used to determine the moment of time shift.