use tkill instead of tgkill in implementing raise

this shaves off a useless syscall for getting the caller's pid and
brings raise into alignment with other functions which were adapted to
use tkill rather than tgkill.

commit 83dc6eb087633abcf5608ad651d3b525ca2ec35e documents the
rationale for this change, and in particular why the tgkill syscall is
useless for its designed purpose of avoiding races.
fix stderr locking and ferror semantics in getopt message printing

if writing the error message fails, POSIX requires that ferror(stderr)
be set. and as a function that operates on a stdio stream, getopt is
required to lock the stream it uses, stderr.

fwrite calls are used instead of fprintf since there is a demand from
some users not to pull in heavy stdio machinery via getopt. this
mimics the original code using write.
support translation for getopt error messages
add error message printing to getopt_long and make related improvements

some related changes are also made to getopt, and the return value of
getopt_long in the case of missing arguments is fixed.
set optopt in getopt_long

this is undocumented but possibly expected behavior of GNU
getopt_long, and useful when error message printing has been
suppressed.
add login_tty function