tcgetsid.c revision 1.2
11.2Sthorpej/*	$NetBSD: tcgetsid.c,v 1.2 1998/02/15 02:41:40 thorpej Exp $	*/
21.1Sthorpej
31.1Sthorpej/*-
41.1Sthorpej * Copyright (c) 1989, 1993
51.1Sthorpej *	The Regents of the University of California.  All rights reserved.
61.1Sthorpej *
71.1Sthorpej * Redistribution and use in source and binary forms, with or without
81.1Sthorpej * modification, are permitted provided that the following conditions
91.1Sthorpej * are met:
101.1Sthorpej * 1. Redistributions of source code must retain the above copyright
111.1Sthorpej *    notice, this list of conditions and the following disclaimer.
121.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
131.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
141.1Sthorpej *    documentation and/or other materials provided with the distribution.
151.1Sthorpej * 3. All advertising materials mentioning features or use of this software
161.1Sthorpej *    must display the following acknowledgement:
171.1Sthorpej *	This product includes software developed by the University of
181.1Sthorpej *	California, Berkeley and its contributors.
191.1Sthorpej * 4. Neither the name of the University nor the names of its contributors
201.1Sthorpej *    may be used to endorse or promote products derived from this software
211.1Sthorpej *    without specific prior written permission.
221.1Sthorpej *
231.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Sthorpej * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Sthorpej * SUCH DAMAGE.
341.1Sthorpej */
351.1Sthorpej
361.1Sthorpej#include <sys/cdefs.h>
371.1Sthorpej#if defined(LIBC_SCCS) && !defined(lint)
381.1Sthorpej#if 0
391.1Sthorpejstatic char sccsid[] = "@(#)termios.c	8.2 (Berkeley) 2/21/94";
401.1Sthorpej#else
411.2Sthorpej__RCSID("$NetBSD: tcgetsid.c,v 1.2 1998/02/15 02:41:40 thorpej Exp $");
421.1Sthorpej#endif
431.1Sthorpej#endif /* LIBC_SCCS and not lint */
441.1Sthorpej
451.1Sthorpej#include "namespace.h"
461.1Sthorpej#include <sys/types.h>
471.1Sthorpej#include <sys/ioctl.h>
481.1Sthorpej#include <termios.h>
491.1Sthorpej#include <unistd.h>
501.1Sthorpej
511.1Sthorpej#ifdef __weak_alias
521.1Sthorpej__weak_alias(tcgetsid,_tcgetsid);
531.1Sthorpej#endif
541.1Sthorpej
551.1Sthorpejpid_t
561.2Sthorpejtcgetsid(fd)
571.1Sthorpej	int fd;
581.1Sthorpej{
591.1Sthorpej	int s;
601.1Sthorpej
611.1Sthorpej	if (ioctl(fd, TIOCGSID, &s) < 0)
621.1Sthorpej		return ((pid_t)-1);
631.1Sthorpej
641.1Sthorpej	return ((pid_t)s);
651.1Sthorpej}
66