Fix process_result locking by acquiring in process_wait as well to prevent freeing memory too early
This commit is contained in:
@@ -647,6 +647,7 @@ init_process_result (struct thread *t)
|
||||
struct process_result *result = malloc (sizeof (struct process_result));
|
||||
result->tid = t->tid;
|
||||
result->exit_status = t->exit_status;
|
||||
lock_init (&result->lock);
|
||||
sema_init (&result->sema, 0);
|
||||
t->result = result;
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user