Fix process_result locking by acquiring in process_wait as well to prevent freeing memory too early

This commit is contained in:
2024-11-08 10:50:10 +00:00
parent 84fe637c7e
commit 6ed1ccd21e
3 changed files with 28 additions and 7 deletions

View File

@@ -34,9 +34,10 @@ typedef int tid_t;
/* A process result, synchronised between parent and child. */
struct process_result
{
tid_t tid; /* The tid of the child process. */
int exit_status; /* The exit status of the child process. Initially set to
-1, then to exit_status when child dies. */
tid_t tid; /* The tid of the child process. */
int exit_status; /* The exit status of the child process. Initially set
to -1, then to exit_status when child dies. */
struct lock lock; /* Lock the exit_status and sema. */
struct semaphore sema; /* Semaphore to signal the parent that the exit_status
has been set. */
struct list_elem elem; /* List element for the parent's children list. */