/* sys/resource.h (for rusage) is required when using osx 10.3 (but not 10.4) */
#ifdef __APPLE__
+#include <TargetConditionals.h>
#include <sys/resource.h>
#ifdef HAVE_LIBPROC_H
/* proc_name */
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/misc-private.h>
-#include <mono/io-layer/mono-mutex.h>
#include <mono/io-layer/process-private.h>
#include <mono/io-layer/threads.h>
#include <mono/utils/strenc.h>
#include <mono/io-layer/timefuncs-private.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-mutex.h>
+#include <mono/utils/mono-signal-handler.h>
/* The process' environment strings */
#if defined(__APPLE__) && !defined (__arm__)
return FALSE;
#ifdef PLATFORM_MACOSX
- if (is_macos_10_5_or_higher ())
- handler = g_strdup ("/usr/bin/open -W");
- else
- handler = g_strdup ("/usr/bin/open");
+ handler = g_strdup ("/usr/bin/open");
#else
/*
* On Linux, try: xdg-open, the FreeDesktop standard way of doing it,
sei->lpDirectory, NULL, &process_info);
g_free (args);
if (!ret){
- SetLastError (ERROR_INVALID_DATA);
+ if (GetLastError () != ERROR_OUTOFMEMORY)
+ SetLastError (ERROR_INVALID_DATA);
return FALSE;
}
+ /* Shell exec should not return a process handle when it spawned a GUI thing, like a browser. */
+ CloseHandle (process_info.hProcess);
+ process_info.hProcess = NULL;
}
if (sei->fMask & SEE_MASK_NOCLOSEPROCESS) {
int startup_pipe [2] = {-1, -1};
int dummy;
struct MonoProcess *mono_process;
+ gboolean fork_failed = FALSE;
mono_once (&process_ops_once, process_ops_init);
mono_once (&process_sig_chld_once, process_add_sigchld_handler);
if (pid == -1) {
/* Error */
SetLastError (ERROR_OUTOFMEMORY);
- _wapi_handle_unref (handle);
+ ret = FALSE;
+ fork_failed = TRUE;
goto cleanup;
} else if (pid == 0) {
/* Child */
if (startup_pipe [0] != -1) {
/* Wait until the parent has updated it's internal data */
- read (startup_pipe [0], &dummy, 1);
+ ssize_t _i G_GNUC_UNUSED = read (startup_pipe [0], &dummy, 1);
DEBUG ("%s: child: parent has completed its setup", __func__);
close (startup_pipe [0]);
close (startup_pipe [1]);
cleanup:
_wapi_handle_unlock_shared_handles ();
+ if (fork_failed)
+ _wapi_handle_unref (handle);
+
if (startup_pipe [1] != -1) {
/* Write 1 byte, doesn't matter what */
- write (startup_pipe [1], startup_pipe, 1);
+ ssize_t _i G_GNUC_UNUSED = write (startup_pipe [1], startup_pipe, 1);
close (startup_pipe [0]);
close (startup_pipe [1]);
}
if (err == 0)
done = TRUE;
- else
+ else {
free (result);
+ result = NULL;
+ }
}
} while (err == 0 && !done);
const struct section *sec;
#endif
const char *name;
- intptr_t slide;
- slide = _dyld_get_image_vmaddr_slide (i);
name = _dyld_get_image_name (i);
- hdr = _dyld_get_image_header (i);
#if SIZEOF_VOID_P == 8
+ hdr = (const struct mach_header_64*)_dyld_get_image_header (i);
sec = getsectbynamefromheader_64 (hdr, SEG_DATA, SECT_DATA);
#else
+ hdr = _dyld_get_image_header (i);
sec = getsectbynamefromheader (hdr, SEG_DATA, SECT_DATA);
#endif
static gboolean match_procname_to_modulename (gchar *procname, gchar *modulename)
{
char* lastsep = NULL;
+ char* lastsep2 = NULL;
char* pname = NULL;
char* mname = NULL;
gboolean result = FALSE;
if (lastsep)
if (!strcmp (lastsep+1, pname))
result = TRUE;
+ if (!result) {
+ lastsep2 = strrchr (pname, '/');
+ if (lastsep2){
+ if (lastsep) {
+ if (!strcmp (lastsep+1, lastsep2+1))
+ result = TRUE;
+ } else {
+ if (!strcmp (mname, lastsep2+1))
+ result = TRUE;
+ }
+ }
+ }
}
g_free (pname);
size_t size;
struct kinfo_proc2 *pi;
#elif defined(PLATFORM_MACOSX)
+#if !(!defined (__mono_ppc__) && defined (TARGET_OSX))
size_t size;
struct kinfo_proc *pi;
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
+#endif
#else
FILE *fp;
gchar *filename = NULL;
}
g_free (filename);
#elif defined(PLATFORM_MACOSX)
-#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) && !defined (__mono_ppc__) && !defined(__arm__)
+#if !defined (__mono_ppc__) && defined (TARGET_OSX)
/* No proc name on OSX < 10.5 nor ppc nor iOS */
memset (buf, '\0', sizeof(buf));
proc_name (pid, buf, sizeof(buf));
}
#if HAVE_SIGACTION
-static void
-mono_sigchld_signal_handler (int _dummy, siginfo_t *info, void *context)
+MONO_SIGNAL_HANDLER_FUNC (static, mono_sigchld_signal_handler, (int _dummy, siginfo_t *info, void *context))
{
int status;
int pid;
fprintf (stdout, "SIG CHILD handler: done looping.");
#endif
}
+
#endif
static void process_add_sigchld_handler (void)