summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-12-12 19:47:23 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-12-12 19:47:23 +0000
commitb7c6a6a8671a192b737c2c652604ddbe454b9f6e (patch)
treeb2442562172b12a89a80deb7856ea1ac24743c82 /term
parenta074a25a39da6481a08761ca6a85e98216123e29 (diff)
(open_hook): Do it differently.
Diffstat (limited to 'term')
-rw-r--r--term/users.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/term/users.c b/term/users.c
index 0d7cb9ad..d4cbf6a3 100644
--- a/term/users.c
+++ b/term/users.c
@@ -90,6 +90,9 @@ open_hook (struct trivfs_control *cntl,
int cancel = 0;
error_t err;
+ if ((flags & (O_READ|O_WRITE)) == 0)
+ return 0;
+
mutex_lock (&global_lock);
if (!(termflags & TTY_OPEN))
@@ -115,36 +118,34 @@ open_hook (struct trivfs_control *cntl,
}
/* Wait for carrier to turn on. */
- if (flags & (O_READ|O_WRITE))
+ while (((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
+ && !(flags & O_NONBLOCK)
+ && !cancel)
{
- while (((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
- && !(flags & O_NONBLOCK)
- && !cancel)
- {
- err = (*bottom->assert_dtr) ();
- if (err)
- {
- mutex_unlock (&global_lock);
- return err;
- }
- cancel = hurd_condition_wait (&carrier_alert, &global_lock);
- }
-
- if ((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
+ err = (*bottom->assert_dtr) ();
+ if (err)
{
mutex_unlock (&global_lock);
- return EWOULDBLOCK;
+ return err;
}
- if (cancel)
- {
- mutex_unlock (&global_lock);
- return EINTR;
- }
-
- termflags |= TTY_OPEN;
- if (!(termstate.c_cflag & CIGNORE))
- (*bottom->set_bits) ();
+ cancel = hurd_condition_wait (&carrier_alert, &global_lock);
+ }
+
+ if ((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
+ {
+ mutex_unlock (&global_lock);
+ return EWOULDBLOCK;
}
+ if (cancel)
+ {
+ mutex_unlock (&global_lock);
+ return EINTR;
+ }
+
+ termflags |= TTY_OPEN;
+ if (!(termstate.c_cflag & CIGNORE))
+ (*bottom->set_bits) ();
+
mutex_unlock (&global_lock);
return 0;