Discussion:
What to do if Read_Line returns -1
(too old to reply)
Eran Kravitz
2005-09-13 01:48:12 UTC
Permalink
In the project description it says to modify the shell to handle the
possibility when Read_Line() returns -1. How are we expected to act when
such a case occurs? Do we need to kill the shell, or print out an error
message, or anything else?

Thanks.
Saurabh Srivastava
2005-09-13 16:27:44 UTC
Permalink
| In the project description it says to modify the shell to handle the
| possibility when Read_Line() returns -1. How are we expected to act when
| such a case occurs? Do we need to kill the shell, or print out an error
| message, or anything else?

You can just Exit the shell.

In the general case, it would be better to have a scenario in which
threads waiting for input were somehow `suspended' on some queue, waiting
to be foregrounded. But that facility being unavailable in GeekOS as of
the moment, you do not have any option but to exit the shell.
cs412
2005-09-19 04:27:37 UTC
Permalink
two questions regarding this:

1. read_line() returns void. how are we supposed to return -1?!
2. ive tried to just Exit like you said, and included kthread.h at the top,
but still it doesnt compile.

somebody please clarify
Post by Saurabh Srivastava
| In the project description it says to modify the shell to handle the
| possibility when Read_Line() returns -1. How are we expected to act when
| such a case occurs? Do we need to kill the shell, or print out an error
| message, or anything else?
You can just Exit the shell.
In the general case, it would be better to have a scenario in which
threads waiting for input were somehow `suspended' on some queue, waiting
to be foregrounded. But that facility being unavailable in GeekOS as of
the moment, you do not have any option but to exit the shell.
Saurabh Srivastava
2005-09-19 18:46:31 UTC
Permalink
| 1. read_line() returns void. how are we supposed to return -1?!

read_line is user space wrapper around Get_Key. Your Get_Key should return
-1 on not being able to read input. When that happens you should handle
that properly in read_line and then you should be able to exit the shell
when that happens.

| 2. ive tried to just Exit like you said, and included kthread.h at the top,
| but still it doesnt compile.

what i meant was that you 'exit' the shell; ie end the user space program
by calling return -1 or something.

Continue reading on narkive:
Loading...