I'm trying to add exit status code to processes in XV6.
I've made the following changes:
1) to sysproc.c
:
int
sys_exit(int status)
{
exit(status);
return 0; // not reached
}
2) to defs.h
:
...
void exit(int);
...
3) to proc.h
:
struct proc {
PCB struct elements...
...
int status; // added
};
4) to proc.c
:
void
exit(int status)
{
struct proc *curproc = myproc();
struct proc *p;
int fd;
cprintf("exit received: %d\n",status); // for debugging purposes
curproc->status = status; // added
...rest of exit system call...
}
5) to user.h
:
// system calls
...
int exit(int) __attribute__((noreturn));
...
Then I wanted to test the added "functionality" by a simple user-space program:
int
main (int argc, char *argv[]) {
exit(3);
}
But the following was printed (notice the cprintf call for debugging in proc.c
):
$ exittest
exit received: -2146420507
What have I done wrong?
Thanks