subr_prf.c (90490) | subr_prf.c (91140) |
---|---|
1/*- 2 * Copyright (c) 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 | 1/*- 2 * Copyright (c) 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 |
39 * $FreeBSD: head/sys/kern/subr_prf.c 90490 2002-02-10 22:04:44Z phk $ | 39 * $FreeBSD: head/sys/kern/subr_prf.c 91140 2002-02-23 11:12:57Z tanimura $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> | 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> |
44#include <sys/lock.h> 45#include <sys/mutex.h> 46#include <sys/sx.h> |
|
44#include <sys/kernel.h> 45#include <sys/msgbuf.h> 46#include <sys/malloc.h> 47#include <sys/proc.h> 48#include <sys/sysctl.h> 49#include <sys/tty.h> 50#include <sys/syslog.h> 51#include <sys/cons.h> --- 56 unchanged lines hidden (view full) --- 108 */ 109int 110uprintf(const char *fmt, ...) 111{ 112 struct thread *td = curthread; 113 struct proc *p = td->td_proc; 114 va_list ap; 115 struct putchar_arg pca; | 47#include <sys/kernel.h> 48#include <sys/msgbuf.h> 49#include <sys/malloc.h> 50#include <sys/proc.h> 51#include <sys/sysctl.h> 52#include <sys/tty.h> 53#include <sys/syslog.h> 54#include <sys/cons.h> --- 56 unchanged lines hidden (view full) --- 111 */ 112int 113uprintf(const char *fmt, ...) 114{ 115 struct thread *td = curthread; 116 struct proc *p = td->td_proc; 117 va_list ap; 118 struct putchar_arg pca; |
116 int retval = 0; | 119 int retval; |
117 | 120 |
118 if (td && td != PCPU_GET(idlethread) && p->p_flag & P_CONTROLT && 119 p->p_session->s_ttyvp) { 120 va_start(ap, fmt); 121 pca.tty = p->p_session->s_ttyp; 122 pca.flags = TOTTY; 123 retval = kvprintf(fmt, putchar, &pca, 10, ap); 124 va_end(ap); | 121 if (td == NULL || td == PCPU_GET(idlethread)) 122 return (0); 123 124 p = td->td_proc; 125 PROC_LOCK(p); 126 if ((p->p_flag & P_CONTROLT) == 0) { 127 PROC_UNLOCK(p); 128 return (0); |
125 } | 129 } |
130 SESS_LOCK(p->p_session); 131 pca.tty = p->p_session->s_ttyp; 132 SESS_UNLOCK(p->p_session); 133 PROC_UNLOCK(p); 134 if (pca.tty == NULL) 135 return (0); 136 pca.flags = TOTTY; 137 va_start(ap, fmt); 138 retval = kvprintf(fmt, putchar, &pca, 10, ap); 139 va_end(ap); 140 |
|
126 return (retval); 127} 128 129/* 130 * tprintf prints on the controlling terminal associated 131 * with the given session, possibly to the log as well. 132 */ 133void 134tprintf(struct proc *p, int pri, const char *fmt, ...) 135{ 136 struct tty *tp = NULL; 137 int flags = 0, shld = 0; 138 va_list ap; 139 struct putchar_arg pca; 140 int retval; 141 142 if (pri != -1) 143 flags |= TOLOG; | 141 return (retval); 142} 143 144/* 145 * tprintf prints on the controlling terminal associated 146 * with the given session, possibly to the log as well. 147 */ 148void 149tprintf(struct proc *p, int pri, const char *fmt, ...) 150{ 151 struct tty *tp = NULL; 152 int flags = 0, shld = 0; 153 va_list ap; 154 struct putchar_arg pca; 155 int retval; 156 157 if (pri != -1) 158 flags |= TOLOG; |
144 if (p && p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { 145 SESSHOLD(p->p_session); 146 shld++; 147 if (ttycheckoutq(p->p_session->s_ttyp, 0)) { 148 flags |= TOTTY; | 159 if (p != NULL) { 160 PGRPSESS_XLOCK(); 161 PROC_LOCK(p); 162 if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { 163 SESS_LOCK(p->p_session); 164 SESSHOLD(p->p_session); |
149 tp = p->p_session->s_ttyp; | 165 tp = p->p_session->s_ttyp; |
150 } | 166 SESS_UNLOCK(p->p_session); 167 PROC_UNLOCK(p); 168 shld++; 169 if (ttycheckoutq(tp, 0)) 170 flags |= TOTTY; 171 else 172 tp = NULL; 173 } else 174 PROC_UNLOCK(p); 175 PGRPSESS_XUNLOCK(); |
151 } 152 pca.pri = pri; 153 pca.tty = tp; 154 pca.flags = flags; 155 va_start(ap, fmt); 156 retval = kvprintf(fmt, putchar, &pca, 10, ap); 157 va_end(ap); | 176 } 177 pca.pri = pri; 178 pca.tty = tp; 179 pca.flags = flags; 180 va_start(ap, fmt); 181 retval = kvprintf(fmt, putchar, &pca, 10, ap); 182 va_end(ap); |
158 if (shld) | 183 if (shld) { 184 PGRPSESS_XLOCK(); 185 SESS_LOCK(p->p_session); |
159 SESSRELE(p->p_session); | 186 SESSRELE(p->p_session); |
187 SESS_UNLOCK(p->p_session); 188 PGRPSESS_XUNLOCK(); 189 } |
|
160 msgbuftrigger = 1; 161} 162 163/* 164 * Ttyprintf displays a message on a tty; it should be used only by 165 * the tty driver, or anything that knows the underlying tty will not 166 * be revoke(2)'d away. Other callers should use tprintf. 167 */ --- 735 unchanged lines hidden --- | 190 msgbuftrigger = 1; 191} 192 193/* 194 * Ttyprintf displays a message on a tty; it should be used only by 195 * the tty driver, or anything that knows the underlying tty will not 196 * be revoke(2)'d away. Other callers should use tprintf. 197 */ --- 735 unchanged lines hidden --- |