Пример #1
0
        /// <summary>
        /// Gets the rusage information for the process identified by the PID
        /// </summary>
        /// <param name="pid">The process to retrieve the rusage for</param>
        /// <returns>On success, returns a struct containing info about the process; on
        /// failure or when the caller doesn't have permissions to the process, throws a Win32Exception
        /// </returns>
        internal static unsafe rusage_info_v3 proc_pid_rusage(int pid)
        {
            // Negative PIDs are invalid
            if (pid < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pid), SR.NegativePidNotSupported);
            }

            rusage_info_v3 info = default;

            // Get the PIDs rusage info
            int result = proc_pid_rusage(pid, RUSAGE_INFO_V3, &info);

            if (result < 0)
            {
                throw new InvalidOperationException(SR.RUsageFailure);
            }

            return(info);
        }
Пример #2
0
        /// <summary>
        /// Gets the rusage information for the process identified by the PID
        /// </summary>
        /// <param name="pid">The process to retrieve the rusage for</param>
        /// <returns>On success, returns a struct containing info about the process; on
        /// failure or when the caller doesn't have permissions to the process, throws a Win32Exception
        /// </returns>
        internal static unsafe rusage_info_v3 proc_pid_rusage(int pid)
        {
            // Negative PIDs are invalid
            if (pid < 0)
            {
                throw new ArgumentOutOfRangeException("pid", SR.NegativePidNotSupported);
            }

            rusage_info_v3 info = new rusage_info_v3();

            // Get the PIDs rusage info
            int result = proc_pid_rusage(pid, RUSAGE_SELF, &info);

            if (result < 0)
            {
                throw new Win32Exception(SR.RUsageFailure);
            }

            return(info);
        }
Пример #3
0
        /// <summary>
        /// Gets the rusage information for the process identified by the PID
        /// </summary>
        /// <param name="pid">The process to retrieve the rusage for</param>
        /// <returns>On success, returns a struct containing info about the process; on
        /// failure or when the caller doesn't have permissions to the process, throws a Win32Exception
        /// </returns>
        internal static unsafe rusage_info_v3 proc_pid_rusage(int pid)
        {
            // Negative PIDs are invalid
            if (pid < 0)
            {
                throw new ArgumentOutOfRangeException("pid", SR.NegativePidNotSupported);
            }

            rusage_info_v3 info = new rusage_info_v3();

            // Get the PIDs rusage info
            int result = proc_pid_rusage(pid, RUSAGE_SELF, &info);
            if (result < 0)
            {
                throw new Win32Exception(SR.RUsageFailure);
            }

            return info;
        }
Пример #4
0
 private static unsafe extern int proc_pid_rusage(
     int pid,
     int flavor,
     rusage_info_v3* rusage_info_t);