コード例 #1
0
        internal static PhpProcessHandle Validate(PhpResource resource)
        {
            PhpProcessHandle result = resource as PhpProcessHandle;

            if (result == null || !result.IsValid)
            {
                PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_process_resource"));
                return(null);
            }

            return(result);
        }
コード例 #2
0
        public static int Close(PhpResource process)
        {
            PhpProcessHandle handle = PhpProcessHandle.Validate(process);

            if (handle == null)
            {
                return(-1);
            }

            var code = CloseProcess(handle.Process);

            handle.Close();
            return(code);
        }
コード例 #3
0
        public static int Terminate(PhpResource process, int signal)
        {
            PhpProcessHandle handle = PhpProcessHandle.Validate(process);

            if (handle == null)
            {
                return(-1);
            }

            try
            {
                handle.Process.Kill();
            }
            catch (Exception e)
            {
                PhpException.Throw(PhpError.Warning, LibResources.GetString("error_terminating_process",
                                                                            handle.Process.ProcessName, handle.Process.Id, e.Message));
                return(-1);
            }
            return(handle.Process.ExitCode);
        }
コード例 #4
0
        public static PhpArray GetStatus(PhpResource process)
        {
            PhpProcessHandle handle = PhpProcessHandle.Validate(process);

            if (handle == null)
            {
                return(null);
            }

            PhpArray result = new PhpArray(0, 8);

            result.Add("command", handle.Command);
            result.Add("pid", handle.Process.Id);
            result.Add("running", !handle.Process.HasExited);
            result.Add("signaled", false);             // UNIX
            result.Add("stopped", false);              // UNIX
            result.Add("exitcode", handle.Process.HasExited ? handle.Process.ExitCode : -1);
            result.Add("termsig", 0);                  // UNIX
            result.Add("stopsig", 0);                  // UNIX

            return(result);
        }