11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* bionic/unistd/tcgetpgrp.c
21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**
31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** Copyright 2006, The Android Open Source Project
41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**
51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** Redistribution and use in source and binary forms, with or without
61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** modification, are permitted provided that the following conditions are met:
71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**     * Redistributions of source code must retain the above copyright
81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**       notice, this list of conditions and the following disclaimer.
91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**     * Redistributions in binary form must reproduce the above copyright
101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**       notice, this list of conditions and the following disclaimer in the
111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**       documentation and/or other materials provided with the distribution.
121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**     * Neither the name of Google Inc. nor the names of its contributors may
131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**       be used to endorse or promote products derived from this software
141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**       without specific prior written permission.
151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project**
161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR
171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project*/
271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <unistd.h>
281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <termios.h>
291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectpid_t tcgetpgrp(int fd)
311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project{
321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    pid_t _pid;
331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    return ioctl(fd, TIOCGPGRP, &_pid) ? (pid_t)-1 : _pid;
341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project}
35