AM_ICONV()
-AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h sys/utime.h semaphore.h sys/un.h linux/rtc.h sys/syscall.h sys/mkdev.h sys/uio.h sys/param.h sys/sysctl.h libproc.h)
+AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h sys/utime.h semaphore.h sys/un.h linux/rtc.h sys/syscall.h sys/mkdev.h sys/uio.h sys/param.h sys/sysctl.h libproc.h sys/prctl.h)
AC_CHECK_HEADERS(sys/param.h sys/socket.h sys/ipc.h sys/sem.h sys/utsname.h alloca.h ucontext.h pwd.h sys/select.h netinet/tcp.h netinet/in.h unistd.h sys/types.h link.h asm/sigcontext.h sys/inotify.h arpa/inet.h complex.h)
AC_CHECK_HEADERS([linux/netlink.h linux/rtnetlink.h],
[], [], [#include <stddef.h>
AC_CHECK_FUNCS(dladdr)
AC_CHECK_FUNCS(sysconf)
AC_CHECK_FUNCS(getrlimit)
+ AC_CHECK_FUNCS(prctl)
AC_CHECK_FUNCS(sched_setaffinity)
AC_CHECK_FUNCS(sched_getcpu)
#include <sys/syscall.h>
#endif
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
#include <mono/metadata/appdomain.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/threads.h>
* it will deadlock. Call the syscall directly instead.
*/
pid = mono_runtime_syscall_fork ();
-
+#if defined (__linux__) && defined (HAVE_PCRTL)
+ if (pid > 0) {
+ // Allow gdb to attach to the process even if ptrace_scope sysctl variable is set to
+ // a value other than 0 (the most permissive ptrace scope). Most modern Linux
+ // distributions set the scope to 1 which allows attaching only to direct children of
+ // the current process
+ prctl (PR_SET_PTRACER, pid, 0, 0, 0);
+ }
+#endif
if (pid == 0) {
dup2 (STDERR_FILENO, STDOUT_FILENO);