# HG changeset patch # User Paul Boddie # Date 1702414927 -3600 # Node ID 2e2ac42bdf28ec07150373177742609b9348c6d5 # Parent d3a47186d0d9c3721a82af4166405f8cdd9eb018 Handle process completion where the output stream has not been closed. diff -r d3a47186d0d9 -r 2e2ac42bdf28 libexec/lib/src/process_monitor.cc --- a/libexec/lib/src/process_monitor.cc Tue Dec 12 19:20:09 2023 +0100 +++ b/libexec/lib/src/process_monitor.cc Tue Dec 12 22:02:07 2023 +0100 @@ -51,13 +51,6 @@ void ProcessMonitor::close() { printf("Process monitor closing...\n"); - - if (l4_is_valid_cap(_task)) - { - ipc_unmap_capability(_task, _mapped_task); - ipc_cap_free_um(_task); - _task = L4_INVALID_CAP; - } } @@ -94,8 +87,9 @@ void ProcessMonitor::pager_ended() { - /* Release the program thread and its reference to this object. This will - cause this object to be closed. */ + /* Release the program thread and its reference to this object, leaving only + the program initiator with a reference. When the initiator releases its + reference, this object will be closed. */ if (l4_is_valid_cap(_thread)) { @@ -105,6 +99,16 @@ ipc_unmap_capability(_task, _mapped_parent); } + + /* Release the program task. This will release any capabilities that might be + blocking the initiator, such as those involving pipes or streams. */ + + if (l4_is_valid_cap(_task)) + { + ipc_unmap_capability(_task, _mapped_task); + ipc_cap_free_um(_task); + _task = L4_INVALID_CAP; + } } diff -r d3a47186d0d9 -r 2e2ac42bdf28 test_files/programs/dstest_exec_payload.c --- a/test_files/programs/dstest_exec_payload.c Tue Dec 12 19:20:09 2023 +0100 +++ b/test_files/programs/dstest_exec_payload.c Tue Dec 12 22:02:07 2023 +0100 @@ -51,8 +51,13 @@ } client_write(output, "Terminating.\n", 13); + + /* NOTE: For inclusion in the C library. */ + client_flush(output); - client_close(output); + + /* NOTE: To test process completion, the output stream is left open. */ + return 0; }