You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bj...@apache.org on 2007/10/30 23:09:58 UTC
svn commit: r590491 - /apr/apr/trunk/file_io/os2/open.c
Author: bjh
Date: Tue Oct 30 15:09:57 2007
New Revision: 590491
URL: http://svn.apache.org/viewvc?rev=590491&view=rev
Log:
OS/2: Make opened files non-inheritable.
Implement apr_file_inherit_set & apr_file_inherit_unset directly instead
of via macros.
Modified:
apr/apr/trunk/file_io/os2/open.c
Modified: apr/apr/trunk/file_io/os2/open.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/os2/open.c?rev=590491&r1=590490&r2=590491&view=diff
==============================================================================
--- apr/apr/trunk/file_io/os2/open.c (original)
+++ apr/apr/trunk/file_io/os2/open.c Tue Oct 30 15:09:57 2007
@@ -33,7 +33,7 @@
APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr_int32_t flag, apr_fileperms_t perm, apr_pool_t *pool)
{
int oflags = 0;
- int mflags = OPEN_FLAGS_FAIL_ON_ERROR|OPEN_SHARE_DENYNONE;
+ int mflags = OPEN_FLAGS_FAIL_ON_ERROR|OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT;
int rv;
ULONG action;
apr_file_t *dafile = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t));
@@ -267,7 +267,34 @@
APR_POOL_IMPLEMENT_ACCESSOR(file);
-APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_file_cleanup)
-APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_file_cleanup)
+APR_DECLARE(apr_status_t) apr_file_inherit_set(apr_file_t *thefile)
+{
+ int rv;
+ ULONG state;
+
+ rv = DosQueryFHState(thefile->filedes, &state);
+
+ if (rv == 0 && (state & OPEN_FLAGS_NOINHERIT) != 0) {
+ rv = DosSetFHState(thefile->filedes, state & ~OPEN_FLAGS_NOINHERIT);
+ }
+
+ return APR_FROM_OS_ERROR(rv);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile)
+{
+ int rv;
+ ULONG state;
+
+ rv = DosQueryFHState(thefile->filedes, &state);
+
+ if (rv == 0 && (state & OPEN_FLAGS_NOINHERIT) == 0) {
+ rv = DosSetFHState(thefile->filedes, state | OPEN_FLAGS_NOINHERIT);
+ }
+
+ return APR_FROM_OS_ERROR(rv);
+}