summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/popen.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r291114: popen() requires check for fdopen() failurerpokala2016-01-091-10/+24
| | | | | | | | Move fdopen() up near other resource allocation like malloc(); do proper deallocation on failure later on in the function. Approved by: jhb Sponsored by: Panasas, Inc.
* popen(): Add 'e' mode character to set close-on-exec on the new fd.jilles2013-05-201-9/+21
| | | | | | | | | | | | | | If 'e' is used, the kernel must support the recently added pipe2() system call. The use of pipe2() with O_CLOEXEC also fixes race conditions between concurrent popen() calls from different threads, even if the close-on-exec flag on the fd of the returned FILE is later cleared (because popen() closes all file descriptors from earlier popen() calls in the child process). Therefore, this approach should be used in all cases when pipe2() can be assumed present. The old version of popen() rejects "re" and "we" but treats "r+e" like "r+".
* Rename the queue macros I introduced last year.ed2009-05-271-1/+1
| | | | | | | | | | | | | | | | Last year I added SLIST_REMOVE_NEXT and STAILQ_REMOVE_NEXT, to remove entries behind an element in the list, using O(1) time. I recently discovered NetBSD also has a similar macro, called SLIST_REMOVE_AFTER. In my opinion this approach is a lot better: - It doesn't have the unused first argument of the list pointer. I added this, mainly because OpenBSD also had it. - The _AFTER suffix makes a lot more sense, because it is related to SLIST_INSERT_AFTER. _NEXT is only used to iterate through the list. The reason why I want to rename this now, is to make sure we don't release a major version with the badly named macros.
* Convert popen()'s `pidlist' to a SLIST, for consistency.ed2008-07-291-11/+13
| | | | | | | | | | | | | I guess the original author of the popen() code didn't want to use our <sys/queue.h> macro's, because the single linked list macro's didn't offer O(1) deletion. Because I introduced SLIST_REMOVE_NEXT() some time ago, we can now use the macro's here. By converting the code to an SLIST, it is more consistent with other parts of the C library and the operating system. Reviewed by: csjp Approved by: philip (mentor, implicit)
* Per Regents of the University of Calfornia letter, remove advertisingimp2007-01-091-4/+0
| | | | | | clause. # If I've done so improperly on a file, please let me know.
* Remove unused variable: omask.tjr2003-01-041-1/+0
|
* Protect pidlist with a mutex to avoid a race causing a duplicate free()tjr2003-01-031-8/+24
| | | | | | | when the same pipe FILE is pclosed()'d in different threads, and to avoid corrupting the linked list when adding or removing items. The symptoms of the linked list getting corrupted were pclose() either not finding the pipe on the list, or the list becoming circular and pclose() looping infinitely.
* * Remove 'register'. (some functions had 7+ register functions...)obrien2002-02-011-3/+3
| | | | * Fix SCM ID's.
* Remove _THREAD_SAFE and make libc thread-safe by default bydeischen2001-01-241-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),jasone2000-01-271-12/+12
| | | | | | | | | | | | | | | | | 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
* Add three-tier symbol naming in support of POSIX thread cancellationjasone2000-01-121-12/+14
| | | | | | 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().
* Conform to POSIX and close any copies of popen() descriptors inherited by amsmith1998-10-151-0/+4
| | | | | | | popen()ed child. PR: misc/7810 Submitted by: Wayne Scott <wscott@ichips.intel.com>
* Avoid the need for calling functions that malloc after a vfork().peter1998-10-111-2/+10
|
* vfork -> fork. The child calls execl() which calls malloc(), sobde1998-10-101-1/+1
| | | | | | | | | vfork() can't be used. We could use alloca() in execl() so that it can be called between vfork() and execve(), but a "portable" popen() shouldn't depend on this. Calling execle() instead of execl() should be fairly safe, since execle() is supposed to be callable from signal handlers and signal handlers can't call malloc(). However, execle() is broken.
* FIxed the cleanup. I forgot to leave stdin alone in the usual (!twoway)bde1997-04-221-1/+2
| | | | case.
* Clean-up my modification of popen.c for vfork. Bruce's (this) is better.dyson1997-04-201-10/+12
| | | | Submitted by: Bruce Evans <bde@freebsd.org>
* Fix the problem in popen that makes correct vfork semantics fail.dyson1997-04-161-6/+11
| | | | | | Specifically, popen modifies a variable "pdes[1]" in the child in such a way that it breaks code in the parent (due to the address space sharing.)
* Fixed cleaning up after malloc failure, which was broken by Lite2.bde1997-03-111-3/+5
| | | | | | We don't use socketpair(), so don't #include <sys/socket.h>. Restored some gcc-quieting parentheses that were lost in the Lite2 merge.
* Merge from Lite2:peter1997-03-111-21/+28
| | | | | filesystem include updates, duplicate group suppression, cleanups, filesystem whiteout support (unionfs), bidir popen().
* General -Wall warning cleanup, part I.jkh1996-07-121-1/+1
| | | | Submitted-By: Kent Vander Velden <graphix@iastate.edu>
* Don't cast void functions to void.hsu1995-06-201-2/+2
| | | | Obtained from: NetBSD commit by jtc on June 16, 1995.
* Remove trailing whitespace.rgrimes1995-05-301-3/+3
|
* BSD 4.4 Lite Lib Sourcesrgrimes1994-05-271-0/+160
OpenPOWER on IntegriCloud