Example #1
0
        public static SignalHandler signal(Signum signum, SignalHandler handler)
        {
            int _sig = NativeConvert.FromSignum(signum);

            Delegate[] handlers = handler.GetInvocationList();
            for (int i = 0; i < handlers.Length; ++i)
            {
                Marshal.Prelink(handlers [i].Method);
            }

            IntPtr r;

            if (handler == SIG_DFL)
            {
                r = sys_signal(_sig, _SIG_DFL);
            }
            else if (handler == SIG_ERR)
            {
                r = sys_signal(_sig, _SIG_ERR);
            }
            else if (handler == SIG_IGN)
            {
                r = sys_signal(_sig, _SIG_IGN);
            }
            else
            {
                r = sys_signal(_sig, handler);
            }
            return(TranslateHandler(r));
        }
Example #2
0
        public static string strerror(Errno errnum)
        {
            int e = NativeConvert.FromErrno(errnum);

            lock (strerror_lock) {
                IntPtr r = sys_strerror(e);
                return(UnixMarshal.PtrToString(r));
            }
        }
Example #3
0
        //
        // <errno.h>  -- COMPLETE
        //

        public static Errno GetLastError()
        {
            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                // On Windows Marshal.GetLastWin32Error() doesn't take errno
                // into account so we need to call Mono_Posix_Stdlib_GetLastError()
                // which returns the value of errno in the C runtime
                // libMonoPosixHelper.dll was linked against.
                return((Errno)_GetLastError());
            }
            return(NativeConvert.ToErrno(Marshal.GetLastWin32Error()));
        }
Example #4
0
        public static string strerror(Errno errnum)
        {
            string str;
            int    num          = NativeConvert.FromErrno(errnum);
            object strerrorLock = Stdlib.strerror_lock;

            Monitor.Enter(strerrorLock);
            try
            {
                str = UnixMarshal.PtrToString(Stdlib.sys_strerror(num));
            }
            finally
            {
                Monitor.Exit(strerrorLock);
            }
            return(str);
        }
Example #5
0
        //
        // <errno.h>  -- COMPLETE
        //

        public static Errno GetLastError()
        {
            // Always call Marshal.GetLastWin32Error() before the OS check,
            // even on Windows where we don't use the return value. If we do
            // the OS check first Environment.OSVersion (if it happens to be
            // the first ever access) will clobber Marshal.GetLastWin32Error()
            // and we won't get the desired errno value on non-Windows platforms.
            int errno = Marshal.GetLastWin32Error();

            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                // On Windows Marshal.GetLastWin32Error() doesn't take errno
                // into account so we need to call Mono_Posix_Stdlib_GetLastError()
                // which returns the value of errno in the C runtime
                // libMonoPosixHelper.dll was linked against.
                errno = _GetLastError();
            }
            return(NativeConvert.ToErrno(errno));
        }
Example #6
0
        public static int chmod(string path, FilePermissions mode)
        {
            uint _mode = NativeConvert.FromFilePermissions(mode);

            return(sys_chmod(path, _mode));
        }
Example #7
0
 public static int raise(RealTimeSignum rts)
 {
     return(sys_raise(NativeConvert.FromRealTimeSignum(rts)));
 }
Example #8
0
 public static int raise(Signum sig)
 {
     return(sys_raise(NativeConvert.FromSignum(sig)));
 }
Example #9
0
 public static int SetSignalAction(RealTimeSignum rts, SignalAction action)
 {
     return(SetSignalAction(NativeConvert.FromRealTimeSignum(rts), action));
 }
Example #10
0
 public static int SetSignalAction(Signum signal, SignalAction action)
 {
     return(SetSignalAction(NativeConvert.FromSignum(signal), action));
 }
Example #11
0
 public static int fseek(IntPtr stream, long offset, SeekFlags origin)
 {
     return(Stdlib.sys_fseek(stream, offset, NativeConvert.FromSeekFlags(origin)));
 }
Example #12
0
        protected static void SetLastError(Errno error)
        {
            int _error = NativeConvert.FromErrno(error);

            SetLastError(_error);
        }
Example #13
0
        //
        // <errno.h>  -- COMPLETE
        //

        public static Errno GetLastError()
        {
            int errno = Marshal.GetLastWin32Error();

            return(NativeConvert.ToErrno(errno));
        }
Example #14
0
        public static int strerror_r(Errno errnum, StringBuilder buf, ulong n)
        {
            int e = NativeConvert.FromErrno(errnum);

            return(sys_strerror_r(e, buf, n));
        }
Example #15
0
        public static int fseek(IntPtr stream, long offset, SeekFlags origin)
        {
            int _origin = NativeConvert.FromSeekFlags(origin);

            return(sys_fseek(stream, offset, _origin));
        }
Example #16
0
 protected static void SetLastError(Errno error)
 {
     Stdlib.SetLastError(NativeConvert.FromErrno(error));
 }
Example #17
0
 public static Errno GetLastError()
 {
     return(NativeConvert.ToErrno(Marshal.GetLastWin32Error()));
 }