4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
43 * This function waits for timo clock ticks for something to arrive on
44 * the specified stream. If more than one client is hanging off of a
45 * single endpoint, and at least one has specified a non-zero timeout,
46 * then all will be woken.
49 * 0 on success or positive error code. On
50 * success, "events" is set to
51 * 0 on timeout or no events(timout = 0),
52 * 1 if desired event has occurred
54 * Most of the code is from strwaitq().
57 #include <sys/param.h>
58 #include <sys/types.h>
62 #include <sys/vnode.h>
63 #include <sys/errno.h>
64 #include <sys/stream.h>
65 #include <sys/ioctl.h>
66 #include <sys/stropts.h>
67 #include <sys/strsubr.h>
68 #include <sys/tihdr.h>
69 #include <sys/timod.h>
70 #include <sys/tiuser.h>
71 #include <sys/t_kuser.h>
72 #include <sys/signal.h>
73 #include <sys/siginfo.h>
75 #include <sys/debug.h>
78 * Poll for an input event.
80 * timo is measured in ticks
83 t_kspoll(TIUSER
*tiptr
, int timo
, int waitflg
, int *events
)
87 klwp_t
*lwp
= ttolwp(curthread
);
88 clock_t timout
; /* milliseconds */
97 if (events
== NULL
|| ((waitflg
& READWAIT
) == 0))
100 /* Convert from ticks to milliseconds */
104 timout
= TICK_TO_MSEC(timo
);
107 * Indicate that the lwp is not to be stopped while doing
108 * this network traffic. This is to avoid deadlock while
109 * debugging a process via /proc.
114 if (waitflg
& NOINTR
)
115 pflag
= MSG_ANY
| MSG_HOLDSIG
;
119 error
= kstrgetmsg(vp
, NULL
, NULL
, &pri
, &pflag
, timout
, &rval
);
124 /* Set the return *events. */
126 if (error
== ETIME
) {