Just came across the tcgetpgrp page. Ugly.
This is fuzzy text that one can guess the intention of.
Not something that belongs in a standard.
pid_t tcgetpgrp(int fildes);
The tcgetpgrp() function shall return the value of the
process group ID of the foreground process group associated
with the terminal.
Flaw #1: "the terminal" - which one? The one associated to fildes perhaps?
Flaw #2: "the foreground process group" - is there one?
If there is no foreground process group, tcgetpgrp() shall return
a value greater than 1 that does not match the process group ID
of any existing process group.
Flaw #3: "there is no foreground process group" - where? In the session
(if any) that has the tty that underlies fildes as controlling tty?
The tcgetpgrp() function is allowed from a process that is a member of a
background process group; however, the information may be subsequently
changed by a process that is a member of a foreground process group.
Flaw #4: "the information" - which information?
And is it really necessary to say that things may change in time?
Upon successful completion, tcgetpgrp() shall return the value of
the process group ID of the foreground process associated with
the terminal. Otherwise, -1 shall be returned and errno set to
indicate the error.
Flaws #5,#6: This "value greater than 1" mentioned above does not equal -1,
so when it is returned tcgetpgrp apparently is successful.
But then there is a "foreground process". (What is that?)
[ENOTTY]
The calling process does not have a controlling terminal,
or the file is not the controlling terminal.
Flaw #7: "the file" - which file?
In other words: the old POSIX text was bad, and the rearrangement
introduced a few errors as well, especially in the description
of the return value.
Andries
|