mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	SystemMenu: Disown child processes after spawning
This commit is contained in:
		
							parent
							
								
									cf624550e5
								
							
						
					
					
						commit
						6e1cb2bae8
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		|  | @ -215,7 +215,12 @@ NonnullRefPtr<GUI::Menu> build_system_menu() | ||||||
|     system_menu->add_action(GUI::Action::create("About...", Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"), [](auto&) { |     system_menu->add_action(GUI::Action::create("About...", Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"), [](auto&) { | ||||||
|         pid_t child_pid; |         pid_t child_pid; | ||||||
|         const char* argv[] = { "/bin/About", nullptr }; |         const char* argv[] = { "/bin/About", nullptr }; | ||||||
|         posix_spawn(&child_pid, "/bin/About", nullptr, nullptr, const_cast<char**>(argv), environ); |         if ((errno = posix_spawn(&child_pid, "/bin/About", nullptr, nullptr, const_cast<char**>(argv), environ))) { | ||||||
|  |             perror("posix_spawn"); | ||||||
|  |         } else { | ||||||
|  |             if (disown(child_pid) < 0) | ||||||
|  |                 perror("disown"); | ||||||
|  |         } | ||||||
|     })); |     })); | ||||||
|     system_menu->add_separator(); |     system_menu->add_separator(); | ||||||
|     system_menu->add_action(GUI::Action::create("Exit...", Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"), [](auto&) { |     system_menu->add_action(GUI::Action::create("Exit...", Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"), [](auto&) { | ||||||
|  | @ -225,7 +230,12 @@ NonnullRefPtr<GUI::Menu> build_system_menu() | ||||||
|             return; |             return; | ||||||
| 
 | 
 | ||||||
|         pid_t child_pid; |         pid_t child_pid; | ||||||
|         posix_spawn(&child_pid, command[0], nullptr, nullptr, const_cast<char**>(command.data()), environ); |         if ((errno = posix_spawn(&child_pid, command[0], nullptr, nullptr, const_cast<char**>(command.data()), environ))) { | ||||||
|  |             perror("posix_spawn"); | ||||||
|  |         } else { | ||||||
|  |             if (disown(child_pid) < 0) | ||||||
|  |                 perror("disown"); | ||||||
|  |         } | ||||||
|     })); |     })); | ||||||
| 
 | 
 | ||||||
|     return system_menu; |     return system_menu; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling