Refactor process_exit to add more comments for readability

This commit is contained in:
sBubshait
2024-11-15 15:35:07 +00:00
parent a7f1d519da
commit 7daf4fb079

View File

@@ -209,7 +209,7 @@ process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
/* filename has already been validated to be a safe-to-access string,
so we can safely use strlen here. Filename has already been
split from the command line arguments. */
push_to_stack (esp, arg, strlen (arg) + 1);
push_to_stack (esp, arg, (strlen (arg) + 1) * sizeof (char));
/* Try to allocate memory for the argument pointer. */
struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem));
@@ -376,9 +376,10 @@ process_exit (void)
/* Clean up all open files */
hash_destroy (&cur->open_files, fd_cleanup);
/* Close the executable file. */
/* Close the executable file, implicitly allowing it to be written to. */
if (cur->exec_file != NULL)
{
/* Acquire the file system lock to prevent race conditions. */
lock_acquire (&filesys_lock);
file_close (cur->exec_file);
lock_release (&filesys_lock);