Merge pull request #1967 from D-POWER/master
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixProcess.cs
index e3f5292206144ab3904be06e6daaf3e9d5ee77f1..3360ef25fe97ad4ed25660646eb8517d73ba95ce 100644 (file)
@@ -4,7 +4,7 @@
 // Authors:
 //   Jonathan Pryor (jonpryor@vt.edu)
 //
-// (C) 2004 Jonathan Pryor
+// (C) 2004-2005 Jonathan Pryor
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -47,15 +47,15 @@ namespace Mono.Unix {
                public bool HasExited {
                        get {
                                int status = GetProcessStatus ();
-                               return Syscall.WIFEXITED (status);
+                               return Native.Syscall.WIFEXITED (status);
                        }
                }
 
                private int GetProcessStatus ()
                {
                        int status;
-                       int r = Syscall.waitpid (pid, out status, 
-                                       WaitOptions.WNOHANG | WaitOptions.WUNTRACED);
+                       int r = Native.Syscall.waitpid (pid, out status, 
+                                       Native.WaitOptions.WNOHANG | Native.WaitOptions.WUNTRACED);
                        UnixMarshal.ThrowExceptionForLastErrorIf (r);
                        return r;
                }
@@ -66,55 +66,55 @@ namespace Mono.Unix {
                                        throw new InvalidOperationException (
                                                        Locale.GetText ("Process hasn't exited"));
                                int status = GetProcessStatus ();
-                               return Syscall.WEXITSTATUS (status);
+                               return Native.Syscall.WEXITSTATUS (status);
                        }
                }
 
                public bool HasSignaled {
                        get {
                                int status = GetProcessStatus ();
-                               return Syscall.WIFSIGNALED (status);
+                               return Native.Syscall.WIFSIGNALED (status);
                        }
                }
 
-               public Signum TerminationSignal {
+               public Native.Signum TerminationSignal {
                        get {
                                if (!HasSignaled)
                                        throw new InvalidOperationException (
                                                        Locale.GetText ("Process wasn't terminated by a signal"));
                                int status = GetProcessStatus ();
-                               return Syscall.WTERMSIG (status);
+                               return Native.Syscall.WTERMSIG (status);
                        }
                }
 
                public bool HasStopped {
                        get {
                                int status = GetProcessStatus ();
-                               return Syscall.WIFSTOPPED (status);
+                               return Native.Syscall.WIFSTOPPED (status);
                        }
                }
 
-               public Signum StopSignal {
+               public Native.Signum StopSignal {
                        get {
                                if (!HasStopped)
                                        throw new InvalidOperationException (
                                                        Locale.GetText ("Process isn't stopped"));
                                int status = GetProcessStatus ();
-                               return Syscall.WSTOPSIG (status);
+                               return Native.Syscall.WSTOPSIG (status);
                        }
                }
 
                public int ProcessGroupId {
-                       get {return Syscall.getpgid (pid);}
+                       get {return Native.Syscall.getpgid (pid);}
                        set {
-                               int r = Syscall.setpgid (pid, value);
+                               int r = Native.Syscall.setpgid (pid, value);
                                UnixMarshal.ThrowExceptionForLastErrorIf (r);
                        }
                }
 
                public int SessionId {
                        get {
-                               int r = Syscall.getsid (pid);
+                               int r = Native.Syscall.getsid (pid);
                                UnixMarshal.ThrowExceptionForLastErrorIf (r);
                                return r;
                        }
@@ -127,17 +127,18 @@ namespace Mono.Unix {
 
                public static int GetCurrentProcessId ()
                {
-                       return Syscall.getpid ();
+                       return Native.Syscall.getpid ();
                }
 
                public void Kill ()
                {
-                       Signal (Signum.SIGKILL);
+                       Signal (Native.Signum.SIGKILL);
                }
 
-               public void Signal (Signum signal)
+               [CLSCompliant (false)]
+               public void Signal (Native.Signum signal)
                {
-                       int r = Syscall.kill (pid, signal);
+                       int r = Native.Syscall.kill (pid, signal);
                        UnixMarshal.ThrowExceptionForLastErrorIf (r);
                }
 
@@ -145,10 +146,9 @@ namespace Mono.Unix {
                {
                        int status;
                        int r;
-                       Error e;
                        do {
-                               r = Syscall.waitpid (pid, out status, (WaitOptions) 0);
-                       } while (r == -1 && (e = Syscall.GetLastError()) == Error.EINTR);
+                               r = Native.Syscall.waitpid (pid, out status, (Native.WaitOptions) 0);
+                       } while (UnixMarshal.ShouldRetrySyscall (r));
                        UnixMarshal.ThrowExceptionForLastErrorIf (r);
                }
        }