delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/18/12:17:25

Date: Wed, 18 Aug 1999 19:07:51 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: tcgetpgrp, tcsetpgrp
Message-ID: <Pine.SUN.3.91.990818190532.10490n-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

I checked in today the following two functions (I don't know how come we 
had them in unistd.h but not in the library).  If anybody sees something 
wrong with them, please say so.

*** /dev/null	Wed Aug 18 09:21:40 1999
--- src/libc/posix/termios/tcgetpgr.c	Wed Aug 18 09:13:12 1999
***************
*** 0 ****
--- 1,20 ----
+ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
+ 
+ #include <libc/stubs.h>
+ #include <unistd.h>
+ #include <errno.h>
+ 
+ pid_t
+ tcgetpgrp (int fd)
+ {
+   int e = errno;
+ 
+   if (isatty (fd))
+     {
+       errno = e;
+       return getpgrp ();
+     }
+   if (!errno)
+     errno = ENOTTY;
+   return -1;
+ }
*** /dev/null	Wed Aug 18 09:21:46 1999
--- src/libc/posix/termios/tcsetpgr.c	Wed Aug 18 09:14:10 1999
***************
*** 0 ****
--- 1,21 ----
+ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
+ 
+ #include <libc/stubs.h>
+ #include <unistd.h>
+ #include <errno.h>
+ 
+ int
+ tcsetpgrp (int fd, pid_t pgid)
+ {
+   int e = errno;
+   pid_t pgrp =  getpgrp ();
+ 
+   if (isatty (fd) && pgid == pgrp)
+     {
+       errno = e;
+       return 0;
+     }
+   if (!errno)
+     errno = pgid == pgrp ? ENOTTY : ENOSYS;
+   return -1;
+ }
*** /dev/null	Wed Aug 18 09:21:57 1999
--- src/libc/posix/termios/tcgetpgr.txh	Wed Aug 18 09:20:58 1999
***************
*** 0 ****
--- 1,58 ----
+ @node tcgetpgrp, termios
+ @subheading Syntax
+ 
+ @example
+ #include <termios.h>
+ 
+ int tcgetpgrp (int fd);
+ @end example
+ 
+ @subheading Description
+ 
+ This function returns the value of the @dfn{process group ID} for the
+ foreground process associated with the terminal.  The file descriptor
+ @var{fd} must be connected to the terminal, otherwise the function will
+ fail.
+ 
+ @subheading Return Value
+ 
+ If @var{fd} is connected to the terminal, the function returns the
+ process group ID, which is currently identical to the value returned by
+ @code{getpgrp()} (@pxref{getpgrp}).  Otherwise, it returns -1 and sets
+ @code{errno} to @code{ENOTTY}.
+ 
+ @subheading Portability
+ 
+ @portability !ansi, posix
+ 
+ @c -------------------------------------------------------------------
+ 
+ @node tcsetpgrp, termios
+ @subheading Syntax
+ 
+ @example
+ #include <termios.h>
+ 
+ int tcsetpgrp (int fd, pid_t pgroup_id);
+ @end example
+ 
+ @subheading Description
+ 
+ This function sets the foreground @dfn{process group ID} for the
+ terminal connected to file descriptor @var{fd}.  @var{fd} must be a
+ valid handle connected to a terminal device, and @var{pgroup_id} must be
+ the process group ID of the calling process, or the function will fail.
+ 
+ @subheading Return Value
+ 
+ If @var{fd} is a valid handle connected to a terminal and
+ @var{pgroup_id} is equal to what @code{getpgrp()} returns
+ (@pxref{getpgrp}), the function will do nothing and return zero.
+ Otherwise, -1 will be returned and @code{errno} will be set to a
+ suitable value.  In particular, if the @var{pgroup_id} argument is
+ different from what @code{getpgrp()} returns, @code{tcsetpgrp} sets
+ @code{errno} to @code{ENOSYS}.
+ 
+ @subheading Portability
+ 
+ @portability !ansi, posix
*** src/libc/posix/termios/makefile.~0	Sun Sep 15 17:02:22 1996
--- src/libc/posix/termios/makefile	Wed Aug 18 09:15:00 1999
***************
*** 12,16 ****
--- 12,18 ----
  SRC += tcsetatr.c
  SRC += tcsndbrk.c
  SRC += tminit.c
+ SRC += tcgetpgr.c
+ SRC += tcsetpgr.c
  
  include $(TOP)/../makefile.inc

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019