mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	 3d7cc471d6
			
		
	
	
		3d7cc471d6
		
	
	
	
	
		
			
			This reverts commit e95eb7a51d.
This is causing some sort of list corruption, as evident by #7313
I haven't been able to figure it out yet, so lets revert this change
until I can figure out what's going on.
		
	
			
		
			
				
	
	
		
			52 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include "ProcessGroup.h"
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| RecursiveSpinLock g_process_groups_lock;
 | |
| InlineLinkedList<ProcessGroup>* g_process_groups;
 | |
| 
 | |
| ProcessGroup::~ProcessGroup()
 | |
| {
 | |
|     ScopedSpinLock lock(g_process_groups_lock);
 | |
|     g_process_groups->remove(this);
 | |
| }
 | |
| 
 | |
| RefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
 | |
| {
 | |
|     auto process_group = adopt_ref_if_nonnull(new ProcessGroup(pgid));
 | |
|     if (process_group) {
 | |
|         ScopedSpinLock lock(g_process_groups_lock);
 | |
|         g_process_groups->prepend(process_group);
 | |
|     }
 | |
| 
 | |
|     return process_group;
 | |
| }
 | |
| 
 | |
| RefPtr<ProcessGroup> ProcessGroup::find_or_create(ProcessGroupID pgid)
 | |
| {
 | |
|     ScopedSpinLock lock(g_process_groups_lock);
 | |
| 
 | |
|     if (auto existing = from_pgid(pgid))
 | |
|         return existing.release_nonnull();
 | |
| 
 | |
|     return create(pgid);
 | |
| }
 | |
| 
 | |
| RefPtr<ProcessGroup> ProcessGroup::from_pgid(ProcessGroupID pgid)
 | |
| {
 | |
|     ScopedSpinLock lock(g_process_groups_lock);
 | |
| 
 | |
|     for (auto& group : *g_process_groups) {
 | |
|         if (group.pgid() == pgid)
 | |
|             return &group;
 | |
|     }
 | |
|     return nullptr;
 | |
| }
 | |
| 
 | |
| }
 |