- Currently, tty::pcon_start flag is cleared before transfer_input()
in master::write(), however, the code in setup_pseudoconsole()
waits for transfer_input() using tty::pcon_start. This possibly
causes the race issue. The patch fixes this potential issue.
- This patch removes the old code which calls transfer_input() but
is no longer needed. These code was necessary indeed in the past,
however, as a result of recent frequent code changes, it is no
longer needed.
- Previously, reset_switch_to_nat_pipe() is called from many places
in pty code. This patch reorganizes that. With this patch, it is
called only from bg_check() and setpgid_aux(). The calls which
does not have enough reason have been omitted.
- To make read() work properly in canonical mode, writing to the pty
pipe should be done line by line. However, only CR was treated as
line separator previously in transfer_input(). This patch fixes
the issue.
- Previously, the PID_NEW_PG flag was also used as a marker for GDB
with non-cygwin inferior, unlike its original meaning. With this
patch, the condition exec_dwProcessId == dwProcessId is used as a
marker for that instead.
glibc getconf doesn't print "undefined" for undefined values
in -a output. It just prints the empty string. Do it the
same way.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
We return -1 with errno set to EINVAL for sysconf options for
values required by POSIX, but not implemented on Cygwin.
This is incorrect. Return -1, but don't set errno for these options.
Drop the "nsup" enum to indicate unsupported values, it's not
required anymore.
Fixes: 59e3b6ca7d (CVS import)
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
When adding the timer_getoverrun function, DELAYTIMER_MAX was added
to limits.h, but the return value of sysconf(_SC_DELAYTIMER_MAX) wasn't
changed accordingly. Fix that now.
Fixes: 9e295a8d19 ("Cygwin: posix timers: implement timer_getoverrun")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- transfer_input() function uses console api, so it should be guarded
by attach_mutex. However, in most cases, it is missing. This patch
fixes the issue.
- This patch communalizes the code for attaching another console
temporarily and resuming to the original attach state, because
there were a plurality of similar codes throughout.
- This patch revises the acquiring/releasing timing for attach_mutex
to make the period in which it is being acquired shorter. Further,
acquiring/releasing are added to where they are missing but needed.
Since we already set up _LIBC to indicate source files are building
for newlib, we don't need this malloc-specific symbol. Convert it
over to simplify the build a bit.
Avoid a recursive make to speed things up a bit.
This drops the header install logic because the lm32/ subdir doesn't
actually have any header files to install.
- In fhandler_console::cons_master_thread(), a struct which has
only a static function is used. In this case, struct instance
is not necessary. So with this patch, the static function is
invoked without creating instance.
So far the values of SigPnd and SigBlk were always 0 and SigIgn
was incorrectly set to the block mask of the current thread of
the calling process.
Fix that by adding a _pinfo::siginfo method and a PICOM_SIGINFO
message to allow to request actual signal info of any running process.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The "how" value only makes sense if a new set is given. If we
only read the current signal set, ignore the value of "how" per
POSIX:
"If set is a null pointer, the value of the argument how is not
significant"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- With this patch, some pty functions/variables have been renamed
so that the name *pcon* is not used for those that are called
even when the pseudo console is not active.
- When Ctrl-C terminates a non-cygwin process on a pseudo console,
pty master attaches to the pseudo console first, and send
CTRL_C_EVENT. If the non-cygwin process closes the pseudo console
before the pty master calls FreeConsole(), the pty master process
will crash. With this patch, pty master process takes over the
ownership of the pseudo console, and closes it by myself.
The current targ-include setup runs `cp` every header file it installs,
in serial. This can be a little noticeable on systems, so cleanup the
logic to rely on cp's ability to copy multiple files to a directory in
a single call.
We still need a check for empty directories with no headers (i.e. the
glob doesn't match anything), so add a helper variable to contain that
logic to reduce the boiler plate a little.
This is a bit of an abbreviated form of what's in the Newlib subdir,
but with emphasis on Libgloss-specific parts, and anything unique to
it. I haven't put too much effort in.
Rather than define per-object rules in the Makefile, have small files
that define & include the right content. This simplifies the build
rules, and makes understanding the source a little easier (imo) as it
makes all the subdirs behave the same: you have 1 source file and it
produces 1 object. It's also about the same amount of boiler plate,
without having to define custom build rules that can fall out of sync.
Some of these rules were already unnecessary as they were compiling a
single source file into the same named object w/out custom flags, and
Automake handles that for us completely.
This will also be important as we merge the libc.a build into the top
dir since it relies on a single flat list of objects for overrides.
Also take the opportunity to clean up the unnecessary header deps in
here. Automake provides dependency generation for free now.
Since POSIX cp requires copying a file to a directory without having
to specify the name explicitly, rely on that to avoid calling basename
on every source file.
We can also drop the stub `true` call if the -f test failed. The use
of `if` already takes care of that in POSIX shell.
- With this patch, unique invisible consoles are created for each pty
to isolate CTRL_C_EVENTs between ptys. This is necessary by Ctrl-C
handling in fhandler_termios::process_sigs() for non-cygwin apps
started in pty if the pseudo console is disabled.
- The commit "Cygwin: console: Prevent the order of typeahead input
from swapped." did not fully resolve the issue. If keys are typed
during input buffer fix, the order of key event may be swapped.
This patch fixes the issue again.
- The recent commit "Cygwin: pinfo: Fix exit code when non-cygwin app
exits by Ctrl-C." did not fix enough the issue. If a non-cygwin app
is reading the console, it will not return STATUS_CONTROL_C_EXIT
even if it is terminated by Ctrl-C. As a result, the previous patch
does not take effect.
This patch solves this issue by setting sigExeced to SIGINT in
ctrl_c_handler(). In addition, sigExeced will be cleared if the app
does not terminated within predetermined time period. The reason is
that the app does not seem to be terminated by the signal sigExeced.
- The commit "Cygwin: console: Fix issues of apps which open pty."
did not fix the second problem correctly. That commit looked to
fix the issue, but the actual problem was that ctrl_c_handler()
should be reregistered *AFTER* FreeConsole()/AttachConsole().
This patch correct that.