xref: /openbsd-src/lib/libc/termios/tcgetsid.c (revision df69c215c7c66baf660f3f65414fd34796c96152)
1*df69c215Sderaadt /*	$OpenBSD: tcgetsid.c,v 1.4 2019/06/28 13:32:42 deraadt Exp $ */
273c3eb76Smillert /*-
373c3eb76Smillert  * Copyright (c) 1989, 1993
473c3eb76Smillert  *	The Regents of the University of California.  All rights reserved.
573c3eb76Smillert  *
673c3eb76Smillert  * Redistribution and use in source and binary forms, with or without
773c3eb76Smillert  * modification, are permitted provided that the following conditions
873c3eb76Smillert  * are met:
973c3eb76Smillert  * 1. Redistributions of source code must retain the above copyright
1073c3eb76Smillert  *    notice, this list of conditions and the following disclaimer.
1173c3eb76Smillert  * 2. Redistributions in binary form must reproduce the above copyright
1273c3eb76Smillert  *    notice, this list of conditions and the following disclaimer in the
1373c3eb76Smillert  *    documentation and/or other materials provided with the distribution.
1473c3eb76Smillert  * 3. Neither the name of the University nor the names of its contributors
1573c3eb76Smillert  *    may be used to endorse or promote products derived from this software
1673c3eb76Smillert  *    without specific prior written permission.
1773c3eb76Smillert  *
1873c3eb76Smillert  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1973c3eb76Smillert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2073c3eb76Smillert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2173c3eb76Smillert  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2273c3eb76Smillert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2373c3eb76Smillert  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2473c3eb76Smillert  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2573c3eb76Smillert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2673c3eb76Smillert  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2773c3eb76Smillert  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2873c3eb76Smillert  * SUCH DAMAGE.
2973c3eb76Smillert  */
3073c3eb76Smillert 
3173c3eb76Smillert #include <sys/ioctl.h>
3273c3eb76Smillert #include <termios.h>
3373c3eb76Smillert 
3473c3eb76Smillert pid_t
tcgetsid(int fd)3573c3eb76Smillert tcgetsid(int fd)
3673c3eb76Smillert {
3773c3eb76Smillert 	int s;
3873c3eb76Smillert 
39*df69c215Sderaadt 	if (ioctl(fd, TIOCGSID, &s) == -1)
40a182690dSmillert 		return (-1);
4173c3eb76Smillert 
42a182690dSmillert 	return (s);
4373c3eb76Smillert }
44