예제 #1
0
        private void InitializeJobObject()
        {
            if (this.jobObject != null) return;

            // Create the JobObject
            this.jobObject = new JobObject("Global\\" + this.user.Username);

            if (this.Rules.CPUPercentageLimit > 0)
            {
                this.JobObject.CPUPercentageLimit = this.Rules.CPUPercentageLimit;
            }

            if (this.Rules.TotalPrivateMemoryLimitBytes > 0)
            {
                this.JobObject.JobMemoryLimitBytes = this.Rules.TotalPrivateMemoryLimitBytes;
            }

            if (this.Rules.ActiveProcessesLimit > 0)
            {
                this.JobObject.ActiveProcessesLimit = this.Rules.ActiveProcessesLimit;
            }

            if (this.Rules.PriorityClass.HasValue)
            {
                this.JobObject.PriorityClass = this.Rules.PriorityClass.Value;
            }

            this.jobObject.KillProcessesOnJobClose = true;
        }
예제 #2
0
        public void Destroy()
        {
            if (!this.isLocked)
            {
                throw new InvalidOperationException("This prison is not locked.");
            }

            Logger.Debug("Destroying prison {0}", this.ID);

            foreach (var cell in prisonCells)
            {
                cell.Destroy(this);
            }

            this.jobObject.TerminateProcesses(-1);

            this.jobObject.Dispose();
            this.jobObject = null;

            // TODO: Should destroy delete the home directory???
            // Directory.CreateDirectory(prisonRules.PrisonHomePath);

            this.TryStopGuard();
            this.UnloadUserProfileUntilReleased();
            this.DeleteUserProfile();
            this.user.Delete();

            SystemRemoveQuota();

            this.DeletePersistedPrirson();
        }