Discussion:
Sys_Wait return codes
(too old to reply)
Daniel Ramsbrock
2005-09-18 15:09:46 UTC
Permalink
The project description reads: "A parent process will not be able to
Wait on any process it spawns in the background; the Sys_Wait system
call will return -1 in this case." Currently, Sys_Wait returns -12 on
any failure (two possibilities: 1. the pid doesn't exist, or 2.
g_currentThread is not its owner).

Should we modify it to return -1 in case 2, where g_currentThread is not
is owner? Or is the -1 return code specific to having been spawned in
the background by the caller (i.e. should we keep the pid of the
detached 'parent' somewhere in User_Context and then return -1 ONLY if
that particular 'parent' is trying to wait on us)?

Or am I just reading into this way too much, and we're supposed to
return -1 in all failure cases? (Even though -12, EINVALID does make
more sense than -1, EUNSPECIFIED).

Thanks,

Daniel
c***@CSIC.UMD.EDU
2005-09-18 15:52:47 UTC
Permalink
I think when the thread is simply not found, we should return -12

When it is not found because the caller is not the owner, then we
should return -1

This way we can distinguish what caused the sys_wait to fail and
not change the original logic.
Daniel Ramsbrock
2005-09-20 00:30:28 UTC
Permalink
I spoke to Dr. Hicks about this after class today:

The confusion arose from the fact that newshell.c was specifically
checking for a -1 return code, rather than just anything less than zero.
Dr. Hicks said that any error return code from Sys_Wait is fine, as long
as it's less than zero. There needs to be no distinction between failure
due to a non-existent PID or failure because the caller is not the
parent of the PID. In other words, the existing code will be just
fine...it returns -12 (EINVALID) in either case. Notice that it will
also handle background processes properly: since they have a NULL owner
pointer, Sys_Wait would fail because the caller (g_currentThread) is not
equal to the owner pointer.

Daniel

Continue reading on narkive:
Loading...