//
static void CreatePipe (out IntPtr read, out IntPtr write, bool writeDirection)
{
+ MonoIOError error;
+
//
// Creates read/write pipe from parent -> child perspective
// a child process uses same descriptors after fork. That's
//
// It can still be tricky for predefined descriptiors http://unixwiz.net/techtips/remap-pipe-fds.html
//
- var ret = MonoIO.CreatePipe (out read, out write);
- if (!ret)
- throw new IOException ("Error creating process pipe");
+ if (!MonoIO.CreatePipe (out read, out write, out error))
+ throw MonoIO.GetException (error);
if (IsWindows) {
const int DUPLICATE_SAME_ACCESS = 0x00000002;
var tmp = writeDirection ? write : read;
- ret = MonoIO.DuplicateHandle (Process.GetCurrentProcess ().Handle, tmp,
- Process.GetCurrentProcess ().Handle, out tmp, 0, 0, DUPLICATE_SAME_ACCESS);
- if (!ret)
- return;
+ if (!MonoIO.DuplicateHandle (Process.GetCurrentProcess ().Handle, tmp, Process.GetCurrentProcess ().Handle, out tmp, 0, 0, DUPLICATE_SAME_ACCESS, out error))
+ throw MonoIO.GetException (error);
- MonoIOError error;
if (writeDirection) {
- MonoIO.Close (write, out error);
+ if (!MonoIO.Close (write, out error))
+ throw MonoIO.GetException (error);
write = tmp;
} else {
- MonoIO.Close (read, out error);
+ if (!MonoIO.Close (read, out error))
+ throw MonoIO.GetException (error);
read = tmp;
}
}
// pipe handles
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static bool CreatePipe (out IntPtr read_handle, out IntPtr write_handle);
+ public extern static bool CreatePipe (out IntPtr read_handle, out IntPtr write_handle, out MonoIOError error);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool DuplicateHandle (IntPtr source_process_handle, IntPtr source_handle,
- IntPtr target_process_handle, out IntPtr target_handle, int access, int inherit, int options);
+ IntPtr target_process_handle, out IntPtr target_handle, int access, int inherit, int options, out MonoIOError error);
// path characters
}
MonoBoolean
-ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle,
- HANDLE *write_handle)
+ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle, HANDLE *write_handle, gint32 *error)
{
SECURITY_ATTRIBUTES attr;
gboolean ret;
MONO_FINISH_BLOCKING;
if(ret==FALSE) {
+ *error = GetLastError ();
/* FIXME: throw an exception? */
return(FALSE);
}
return(TRUE);
}
-MonoBoolean ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle,
- HANDLE source_handle, HANDLE target_process_handle, HANDLE *target_handle,
- gint32 access, gint32 inherit, gint32 options)
+MonoBoolean
+ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle, HANDLE source_handle,
+ HANDLE target_process_handle, HANDLE *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error)
{
/* This is only used on Windows */
gboolean ret;
MONO_FINISH_BLOCKING;
if(ret==FALSE) {
+ *error = GetLastError ();
/* FIXME: throw an exception? */
return(FALSE);
}
ves_icall_System_IO_MonoIO_get_ConsoleError (void);
extern MonoBoolean
-ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle,
- HANDLE *write_handle);
+ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle, HANDLE *write_handle, gint32 *error);
-extern MonoBoolean ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle,
- HANDLE source_handle, HANDLE target_process_handle, HANDLE *target_handle,
- gint32 access, gint32 inherit, gint32 options);
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle, HANDLE source_handle,
+ HANDLE target_process_handle, HANDLE *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error);
extern gunichar2
ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar (void);
#ifndef PLATFORM_RO_FS
ICALL(MONOIO_2, "CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile)
ICALL(MONOIO_3, "CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory)
-ICALL(MONOIO_4, "CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe)
+ICALL(MONOIO_4, "CreatePipe", ves_icall_System_IO_MonoIO_CreatePipe)
ICALL(MONOIO_5, "DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile)
#endif /* !PLATFORM_RO_FS */
ICALL(MONOIO_34, "DuplicateHandle", ves_icall_System_IO_MonoIO_DuplicateHandle)