mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-30 21:01:00 +00:00 
			
		
		
		
	 8c5e64e686
			
		
	
	
		8c5e64e686
		
	
	
	
	
		
			
			On macOS, it's not trivial to get a Mach task port for your children. This implementation registers the chrome process as a well-known service with launchd based on its pid, and lets each child process send over a reference to its mach_task_self() back to the chrome. We'll need this Mach task port right to get process statistics.
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			810 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			810 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Platform.h>
 | |
| 
 | |
| #if !defined(AK_OS_MACH)
 | |
| #    error "This file is only available on Mach platforms"
 | |
| #endif
 | |
| 
 | |
| #include <LibWebView/Platform/ProcessStatistics.h>
 | |
| #include <mach/mach.h>
 | |
| 
 | |
| namespace WebView {
 | |
| 
 | |
| struct ChildPortMessage {
 | |
|     mach_msg_header_t header;
 | |
|     mach_msg_body_t body;
 | |
|     mach_msg_port_descriptor_t port_descriptor;
 | |
| };
 | |
| 
 | |
| struct ParentPortMessage {
 | |
|     mach_msg_header_t header;
 | |
|     mach_msg_body_t body;
 | |
|     mach_msg_port_descriptor_t port_descriptor;
 | |
|     mach_msg_audit_trailer_t trailer; // for the child's pid
 | |
| };
 | |
| 
 | |
| static constexpr mach_msg_id_t SELF_TASK_PORT_MESSAGE_ID = 0x1234CAFE;
 | |
| 
 | |
| void register_with_mach_server(ByteString const& server_name);
 | |
| 
 | |
| }
 |