summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sal/osl/unx/createfilehandlefromfd.hxx45
-rw-r--r--sal/osl/unx/file.cxx8
-rw-r--r--sal/osl/unx/process.cxx (renamed from sal/osl/unx/process.c)55
3 files changed, 79 insertions, 29 deletions
diff --git a/sal/osl/unx/createfilehandlefromfd.hxx b/sal/osl/unx/createfilehandlefromfd.hxx
new file mode 100644
index 000000000000..116c074a2ce1
--- /dev/null
+++ b/sal/osl/unx/createfilehandlefromfd.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ * developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef INCLUDED_SAL_OSL_UNX_CREATEFILEHANDLEFROMFD_HXX
+#define INCLUDED_SAL_OSL_UNX_CREATEFILEHANDLEFROMFD_HXX
+
+#include "sal/config.h"
+
+#include "osl/file.h"
+
+namespace osl { namespace detail {
+
+oslFileHandle createFileHandleFromFD(int fd); // defined in file.cxx
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 1bf76a81f08e..f0604131e34a 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -33,6 +33,7 @@
#include "rtl/alloc.h"
#include "system.h"
+#include "createfilehandlefromfd.hxx"
#include "file_error_transl.h"
#include "file_url.h"
@@ -762,10 +763,7 @@ oslFileError FileHandle_Impl::syncFile()
return (result);
}
-/****************************************************************************
- * osl_createFileHandleFromFD
- ***************************************************************************/
-extern "C" oslFileHandle osl_createFileHandleFromFD( int fd )
+oslFileHandle osl::detail::createFileHandleFromFD( int fd )
{
if (-1 == fd)
return 0; // EINVAL
@@ -791,7 +789,7 @@ extern "C" oslFileHandle osl_createFileHandleFromFD( int fd )
pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);
}
- OSL_FILE_TRACE("osl_createFileHandleFromFD(%d, writeable) => %s",
+ OSL_FILE_TRACE("osl::detail::createFileHandleFromFD(%d, writeable) => %s",
pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath));
return (oslFileHandle)(pImpl);
}
diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.cxx
index 424056744c21..c35a340c419b 100644
--- a/sal/osl/unx/process.c
+++ b/sal/osl/unx/process.cxx
@@ -26,6 +26,9 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <cassert>
/*
* ToDo:
@@ -60,15 +63,17 @@
#include <osl/file.h>
#include <osl/signal.h>
#include <rtl/alloc.h>
+#include <sal/log.hxx>
#include <grp.h>
+#include "createfilehandlefromfd.hxx"
+#include "file_url.h"
#include "procimpl.h"
#include "readwrite_helper.h"
#include "sockimpl.h"
#include "secimpl.h"
-
#define MAX_ARGS 255
#define MAX_ENVS 255
@@ -76,10 +81,6 @@
#define CONTROLLEN (sizeof(struct cmsghdr) + sizeof(int))
#endif
-/* implemented in file.c */
-extern oslFileError FileURLToPath( char *, size_t, rtl_uString* );
-extern oslFileHandle osl_createFileHandleFromFD( int fd );
-
/******************************************************************************
*
* Data Type Definition
@@ -107,12 +108,6 @@ typedef struct {
oslFileHandle *m_pErrorRead;
} ProcessData;
-typedef struct _oslPipeImpl {
- int m_Socket;
- sal_Char m_Name[PATH_MAX + 1];
-} oslPipeImpl;
-
-
/******************************************************************************
*
* Function Declarations
@@ -443,7 +438,7 @@ static void ChildStatusProc(void *pData)
{
pid_t pid = -1;
int status = 0;
- int channel[2];
+ int channel[2] = { -1, -1 };
ProcessData data;
ProcessData *pdata;
int stdOutput[2] = { -1, -1 }, stdInput[2] = { -1, -1 }, stdError[2] = { -1, -1 };
@@ -459,23 +454,35 @@ static void ChildStatusProc(void *pData)
#define fork() (errno = EINVAL, -1)
#endif
if (socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == -1)
+ {
status = errno;
+ SAL_WARN("sal", "executeProcess socketpair() errno " << status);
+ }
fcntl(channel[0], F_SETFD, FD_CLOEXEC);
fcntl(channel[1], F_SETFD, FD_CLOEXEC);
/* Create redirected IO pipes */
- if ( status == 0 && data.m_pInputWrite )
- if (pipe( stdInput ) == -1)
- status = errno;
+ if ( status == 0 && data.m_pInputWrite && pipe( stdInput ) == -1 )
+ {
+ status = errno;
+ assert(status != 0);
+ SAL_WARN("sal", "executeProcess pipe(stdInput) errno " << status);
+ }
- if ( status == 0 && data.m_pOutputRead )
- if (pipe( stdOutput ) == -1)
- status = errno;
+ if ( status == 0 && data.m_pOutputRead && pipe( stdOutput ) == -1 )
+ {
+ status = errno;
+ assert(status != 0);
+ SAL_WARN("sal", "executeProcess pipe(stdOutput) errno " << status);
+ }
- if ( status == 0 && data.m_pErrorRead )
- if (pipe( stdError ) == -1)
- status = errno;
+ if ( status == 0 && data.m_pErrorRead && pipe( stdError ) == -1 )
+ {
+ status = errno;
+ assert(status != 0);
+ SAL_WARN("sal", "executeProcess pipe(stdError) errno " << status);
+ }
if ( (status == 0) && ((pid = fork()) == 0) )
{
@@ -601,13 +608,13 @@ static void ChildStatusProc(void *pData)
/* Store used pipe ends in data structure */
if ( pdata->m_pInputWrite )
- *(pdata->m_pInputWrite) = osl_createFileHandleFromFD( stdInput[1] );
+ *(pdata->m_pInputWrite) = osl::detail::createFileHandleFromFD( stdInput[1] );
if ( pdata->m_pOutputRead )
- *(pdata->m_pOutputRead) = osl_createFileHandleFromFD( stdOutput[0] );
+ *(pdata->m_pOutputRead) = osl::detail::createFileHandleFromFD( stdOutput[0] );
if ( pdata->m_pErrorRead )
- *(pdata->m_pErrorRead) = osl_createFileHandleFromFD( stdError[0] );
+ *(pdata->m_pErrorRead) = osl::detail::createFileHandleFromFD( stdError[0] );
osl_releaseMutex(ChildListMutex);