summaryrefslogtreecommitdiff
path: root/lib/libc/gen/exec.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove warnings from exec.c.Ed Schouten2009-12-051-20/+19
| | | | | | | | | | | The entries in the argv array are not const themselves, but sometimes we want to fill in const values. Just make the array const and use __DECONST() to make it const for the execve()-call itself. Also convert the only K&R prototype to ANSI. Notes: svn path=/head/; revision=200136
* Properly use the envp argument in execvPe().Ed Schouten2009-11-271-2/+2
| | | | | | | | | | | | | | | | | | execvPe() is called by _execvpe(), which we added to implement posix_spawnp(). We just took execvP() and added the envp argument. Unfortunately we forgot to change the implementation to use envp over environ. This fixes the following piece of code: | char * const arg[2] = { "env", NULL }; | char * const env[2] = { "FOO=BAR", NULL }; | posix_spawnp(NULL, "/usr/bin/env", NULL, NULL, arg, env); MFC after: 2 weeks Notes: svn path=/head/; revision=199862
* Turn execvpe() into an internal libc routine.Ed Schouten2008-06-231-2/+3
| | | | | | | | | | | | | | | Adding exevpe() has caused some ports to break. Even though execvpe() is a useful routine, it does not conform to any standards. This patch is a little bit different from the patch sent to the mailing list. I forgot to remove execvpe from the Symbol.map (which does not seem to miscompile libc, though). Reviewed by: davidxu Approved by: philip Notes: svn path=/head/; revision=179947
* Add POSIX routines called posix_spawn() and posix_spawnp(), whichDavid Xu2008-06-171-9/+22
| | | | | | | | | | | | can be used as replacements for exec/fork in a lot of cases. This change also added execvpe() which allows environment variable PATH to be used for searching executable file, it is used for implementing posix_spawnp(). PR: standards/122051 Notes: svn path=/head/; revision=179838
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-091-4/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Fixed some style bugs.Bruce Evans2003-07-011-6/+7
| | | | Notes: svn path=/head/; revision=117111
* Add a libc function execvP that takes the search path as an arguement.Gordon Tetlow2003-06-291-8/+16
| | | | | | | | | | | Change execvp to be a wrapper around execvP. This is necessary for some of the /rescue pieces. It may also be more generally applicable as well. Submitted by: Tim Kientzle <kientzle@acm.org> Approved by: Silence on arch@ Notes: svn path=/head/; revision=117030
* Remove an unused variable, `sverrno', which has not been used since 1.11.Tim J. Robbins2003-01-031-1/+0
| | | | Notes: svn path=/head/; revision=108620
* Assume __STDC__, remove non-__STDC__ code.Alfred Perlstein2002-05-281-49/+0
| | | | | | | Submitted by: keramida Notes: svn path=/head/; revision=97407
* * Remove 'register'. (some functions had 7+ register functions...)David E. O'Brien2002-02-011-6/+4
| | | | | | | * Fix SCM ID's. Notes: svn path=/head/; revision=90041
* Removed duplicate VCS ID tags, as per style(9).Ruslan Ermilov2001-08-131-2/+0
| | | | Notes: svn path=/head/; revision=81586
* Remove _THREAD_SAFE and make libc thread-safe by default byDaniel Eischen2001-01-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch Notes: svn path=/head/; revision=71579
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),Jason Evans2000-01-271-3/+3
| | | | | | | | | | | | | | | | | | | | just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen Notes: svn path=/head/; revision=56698
* Add three-tier symbol naming in support of POSIX thread cancellationJason Evans2000-01-121-3/+6
| | | | | | | | | points. For library functions, the pattern is __sleep() <-- _libc_sleep() <-- sleep(). The arrows represent weak aliases. For system calls, the pattern is _read() <-- _libc_read() <-- read(). Notes: svn path=/head/; revision=55837
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Fix a (relatively harmless) braino. I confused myself over the for() loopPeter Wemm1999-03-241-3/+2
| | | | | | | | | | | | that counted the number of elements in argv. The counter is incremented in the next-iteration section of the loop, not the body, so at termination it's already "counted" the element that failed the continuation test - in this case the NULL argv terminator. Noted by: bde Notes: svn path=/head/; revision=44984
* Remove last remaining references to malloc/realloc and functions thatPeter Wemm1999-03-231-50/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | call them. All the execX() libc functions should be vfork() safe now. Specifically: - execlp() does the argument count-and-build into a vector from alloca (like the others) - buildargv() is no longer used (and gone). - execvp() uses alloca/strcpy rather than strdup(). - the ENOEXEC handler uses alloca rather than malloc. - a couple of free() calls removed - alloca works on the local stack and the allocations are freed on function exit (which is why buildargv wasn't useful - it's alloca() context would disappear on return). Along the way: - If alloca() fails (can it?), set errno = ENOMEM explicitly. - The ENOEXEC recovery routine that trys again with /bin/sh appeared to not be terminating the new argv[] array for /bin/sh, allowing it to walk off the end of the list. I dithered a bit about using alloca() even more as it's most commonly associated with gcc. However, standalone portable (using malloc) and machine-specific assembler alloca implementations appear to be available on just about all the architectures we're likely to want to port to. alloca will be the least of our problems if ever going to another compiler. Notes: svn path=/head/; revision=44974
* Fix style issues in execl(), and make execle() vfork()-safe.Dag-Erling Smørgrav1998-10-151-13/+23
| | | | | | | | Reviewed by: bde Approved by: jkh Notes: svn path=/head/; revision=40396
* Correct braino in previous commit. I get the pointy hat again.Dag-Erling Smørgrav1998-10-141-3/+4
| | | | Notes: svn path=/head/; revision=40357
* Make execl() vfork()-safe. This should fix potential bugs in rcp,Dag-Erling Smørgrav1998-10-141-8/+20
| | | | | | | | | | telnet and tip, and probably a few other apps. Reviewed by: bde Approved by: jkh Notes: svn path=/head/; revision=40356
* stat() the correct file in execvp() so that the fine tuned errno handlingBruce Evans1997-11-201-2/+2
| | | | | | | actually works. Notes: svn path=/head/; revision=31309
* Fixed searching of $PATH in execvp(). Do what sh(1) should do accordingBruce Evans1997-10-141-9/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to POSIX.2. In particular: - don't retry for ETXTBSY. This matches what sh(1) does. The retry code was broken anyway. It only slept for several seconds for the first few retries. Then it retried without sleeping. - don't abort the search for errors related to the path prefix, in particular for ENAMETOOLONG, ENOTDIR, ELOOP. This fixes PR1487. sh(1) gets this wrong in the opposite direction by never aborting the search. - don't confuse EACCES for errors related to the path prefix with EACCES for errors related to the file. sh(1) gets this wrong. - don't return a stale errno when the search terminates normally without finding anything. The errno for the last unsuccessful execve() was usually returned. This gave too much precedence to pathologies in the last component of $PATH. This bug is irrelevant for sh(1). The implementation still uses the optimization/race-inhibitor of trying to execve() things first. POSIX.2 seems to require looking at file permissions using stat(). We now use stat() after execve() if execve() fails with an ambiguous error. Trying execve() first may actually be a pessimization, since failing execve()s are fundamentally a little slower than stat(), and are significantly slower when a file is found but has unsuitable permissions or points to an unsuitable interpreter. PR: 1487 Notes: svn path=/head/; revision=30399
* Fixed execvp() of an empty pathname to fail POSIXly. Previously itBruce Evans1996-11-181-0/+6
| | | | | | | | | | attempted to exec the components of $PATH and it usually set errno to the wrong value. Found by: NIST PCTS Notes: svn path=/head/; revision=19852
* Fixed uninitialized variables for the '/'-in-pathname case in execvp().Bruce Evans1996-11-181-1/+2
| | | | | | | | | | | Garbage in `eacces' caused the wrong errno to be set for non-EACCES errors. Garbage in `etxtbsy' caused a semi-random retry strategy for ETXTBSY errors. Found by: NIST-PCTS. gcc -Wall reported the problem, but -Wall is not enabled for libc. Notes: svn path=/head/; revision=19850
* General -Wall warning cleanup, part I.Jordan K. Hubbard1996-07-121-4/+4
| | | | | | | Submitted-By: Kent Vander Velden <graphix@iastate.edu> Notes: svn path=/head/; revision=17141
* Fix execl[e]. Multiple execle's failed because of bogus caching of theBruce Evans1994-12-121-16/+14
| | | | | | | | | | | pointer returned by realloc(). All callers free the pointer if the execve fails. Nuke the caching. This essentially restores buildargv() to the 1.1.5 version. Also fix a memory leak if realloc() fails. Also nuke similar but non-broken caching in execvp(). malloc() should be efficient enough. Notes: svn path=/head/; revision=5070
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-271-0/+271
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573