1.1 --- a/libexec/lib/src/process_creator_context_resource.cc Mon Apr 03 22:10:42 2023 +0200
1.2 +++ b/libexec/lib/src/process_creator_context_resource.cc Tue Apr 04 23:11:00 2023 +0200
1.3 @@ -67,9 +67,27 @@
1.4 printf("argv[%d] = %s\n", i, argv[i]);
1.5 }
1.6
1.7 - /* Start the new process, obtaining a reference to it. */
1.8 + /* Obtain a reference to a new process and send the reference to the client.
1.9 + This must be done in advance of actually starting the program since the
1.10 + program may complete before the client gets the reference. */
1.11 +
1.12 + long err = _creator->init_process(process);
1.13 +
1.14 + if (!err)
1.15 + err = complete_ProcessCreatorContext_start(*process);
1.16 +
1.17 + /* Attempt to communicate any error from these activities. */
1.18
1.19 - return _creator->start(argc, argv, process);
1.20 + if (err)
1.21 + return err;
1.22 +
1.23 + /* Attempt to actually start the process. Errors cannot be communicated as a
1.24 + reply, so a notification is sent via the process monitor instead by the
1.25 + process creator. */
1.26 +
1.27 + _creator->start(argc, argv, *process);
1.28 +
1.29 + return IPC_MESSAGE_SENT;
1.30 }
1.31
1.32 /* vim: tabstop=4 expandtab shiftwidth=4