tcgetsid.c revision 1.6
11.6Sagc/* $NetBSD: tcgetsid.c,v 1.6 2003/08/07 16:44:13 agc 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.6Sagc * 3. Neither the name of the University nor the names of its contributors 161.1Sthorpej * may be used to endorse or promote products derived from this software 171.1Sthorpej * without specific prior written permission. 181.1Sthorpej * 191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221.1Sthorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291.1Sthorpej * SUCH DAMAGE. 301.1Sthorpej */ 311.1Sthorpej 321.1Sthorpej#include <sys/cdefs.h> 331.1Sthorpej#if defined(LIBC_SCCS) && !defined(lint) 341.1Sthorpej#if 0 351.1Sthorpejstatic char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94"; 361.1Sthorpej#else 371.6Sagc__RCSID("$NetBSD: tcgetsid.c,v 1.6 2003/08/07 16:44:13 agc Exp $"); 381.1Sthorpej#endif 391.1Sthorpej#endif /* LIBC_SCCS and not lint */ 401.1Sthorpej 411.1Sthorpej#include "namespace.h" 421.1Sthorpej#include <sys/types.h> 431.1Sthorpej#include <sys/ioctl.h> 441.3Slukem 451.3Slukem#include <assert.h> 461.3Slukem#include <errno.h> 471.1Sthorpej#include <termios.h> 481.1Sthorpej#include <unistd.h> 491.1Sthorpej 501.1Sthorpej#ifdef __weak_alias 511.5Smycroft__weak_alias(tcgetsid,_tcgetsid) 521.1Sthorpej#endif 531.1Sthorpej 541.1Sthorpejpid_t 551.2Sthorpejtcgetsid(fd) 561.1Sthorpej int fd; 571.1Sthorpej{ 581.1Sthorpej int s; 591.3Slukem 601.3Slukem _DIAGASSERT(fd != -1); 611.1Sthorpej 621.1Sthorpej if (ioctl(fd, TIOCGSID, &s) < 0) 631.1Sthorpej return ((pid_t)-1); 641.1Sthorpej 651.1Sthorpej return ((pid_t)s); 661.1Sthorpej} 67