1 /* 2 * A resource offering support for creating processes. 3 * 4 * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <fsserver/resource_server.h> 23 24 #include "opener_server.h" 25 #include "process_creating.h" 26 #include "process_creator_context_resource.h" 27 #include "process_creator_resource.h" 28 29 30 31 /* Support for creating processes. */ 32 33 ProcessCreatorResource::ProcessCreatorResource(const char *rm_filename) 34 : _creating(rm_filename) 35 { 36 } 37 38 ProcessCreatorResource::~ProcessCreatorResource() 39 { 40 } 41 42 ipc_server_default_config_type ProcessCreatorResource::config() 43 { 44 return config_Opener; 45 } 46 47 48 49 /* ProcessCreator interface methods. */ 50 51 /* Start the new process, obtaining a reference to it. */ 52 53 long ProcessCreatorResource::start(int argc, const char *argv[], l4_cap_idx_t *process) 54 { 55 return _creating.start(argc, argv, process); 56 } 57 58 59 60 /* Opener interface methods. */ 61 62 /* Return a context, through which program arguments must be communicated. */ 63 64 long ProcessCreatorResource::context(l4_cap_idx_t *context) 65 { 66 ProcessCreatorContextResource *resource = new ProcessCreatorContextResource(this); 67 68 /* Complete the initialisation and start a server in a new thread. 69 If the thread does not start, the resource will be finalised. */ 70 71 return ResourceServer(resource).start_thread(context); 72 } 73 74 // vim: tabstop=4 expandtab shiftwidth=4