Commit Graph

20428 Commits

Author SHA1 Message Date
Takashi Yano 51095fe2ba Cygwin: pty: Fix a possible race issue in initialization of pcon.
- 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.
2022-03-04 22:23:39 +09:00
Takashi Yano 3d46583d4f Cygwin: pty: Update some comments in pty code. 2022-03-04 22:00:24 +09:00
Takashi Yano bb98c26e16 Cygwin: pty: Omit transfer_input() call where it is no longer needed.
- 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.
2022-03-04 20:04:24 +09:00
Takashi Yano e93c7cb571 Cygwin: pty: Rearrange reset_switch_to_nat_pipe() calls.
- 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.
2022-03-04 20:04:15 +09:00
Takashi Yano a263b94b5e Cygwin: pty: Treat both CR and NL as line feed in transfer_inpup().
- 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.
2022-03-04 20:04:02 +09:00
Mike Frysinger 845515267b libgloss: add new Build System Internals node to the menu
Seems that some versions of texinfo require the @menu to have all
entries at the top level, so add the new build one to it.
2022-03-04 01:04:25 -05:00
Takashi Yano 261acf7318 Cygwin: pty: Stop to use PID_NEW_PG flag as a marker for GDB.
- 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.
2022-03-04 03:18:30 +09:00
Takashi Yano efd153853c Cygwin: pty: Simplify the setup code for GDB a bit.
- This patch omits the unnecessary code path for setup for GDB.
2022-03-04 03:17:03 +09:00
Takashi Yano d6b778617d Cygwin: pty: Rename nat_pipe_owner_alive() to process_alive().
- The function nat_pipe_owner_alive() is used even for the process
  which is not a nat pipe owner, so, it is renamed to process_alive().
2022-03-04 03:16:52 +09:00
Corinna Vinschen 35ba7d147d Cygwin: getconf: align -a output to glibc getconf
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>
2022-03-02 22:15:02 +01:00
Corinna Vinschen fcec4830ab Cygwin: sysconf: don't set errno for unsupported options
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>
2022-03-02 22:02:59 +01:00
Corinna Vinschen cf00bba99a Cygwin: sysconf: belatedly add correct return value for _SC_DELAYTIMER_MAX
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>
2022-03-02 22:02:44 +01:00
Takashi Yano 2b3a70d0a6 Cygwin: pty: Add still missing acquire/release_attach_mutex.
- 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.
2022-03-03 04:41:20 +09:00
Takashi Yano df24c3d3c6 Cygwin: pty: Communalize the code for temporary attach to console.
- 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.
2022-03-02 21:35:40 +09:00
Takashi Yano 5f4e7b0368 Cygwin: console, pty: Revamp the acquire/release_attach_mutex timing.
- 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.
2022-03-02 19:20:48 +09:00
Corinna Vinschen 42e23c5ad2 Cygwin: _pinfo::siginfo: fix sig_send call
Request __SIGPENDINGALL, not __SIGPENDING, when fetching signal info
for the calling process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 09:48:01 +01:00
Takashi Yano 312dc2289c Cygwin: console: Fix a bug from comparison between int and DWORD. 2022-03-02 11:18:01 +09:00
Mike Frysinger dea52d5c1e newlib: convert INTERNAL_NEWLIB to _LIBC
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.
2022-03-01 20:30:32 -05:00
Mike Frysinger e15b2e8691 newlib: drop redundant AM_MAINTAINER_MODE call
This is already called earlier in this file, so no need to do it again.
2022-03-01 20:30:05 -05:00
Mike Frysinger 74885d4fbd libgloss: merge lm32 into top-level Makefile
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.
2022-03-01 20:29:07 -05:00
Mike Frysinger 89f643e87b libgloss: use m4_foreach_w to simplify the logic a bit
It's functionally the same, but the configure.ac code is simpler and
less boiler plate duplicated.
2022-03-01 20:29:07 -05:00
Takashi Yano 020fa7ed7b Cygwin: console: Prevent special keys processing from drop.
- There was a potential risk to drop special key processing when
  process_input_messsage() is called intermittently. This patch
  fixes the issue.
2022-03-02 09:55:52 +09:00
Takashi Yano 2b4d4728f2 Cygwin: console: Stop to create struct instance which is not needed.
- 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.
2022-03-02 08:47:03 +09:00
Corinna Vinschen 3e4dd6cc48 Cygwin: update 3.4 release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:27:10 +01:00
Corinna Vinschen 9a3c058f66 Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life
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>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 195169186b Cygwin: wait_sig: allow to compute process-wide mask of pending signals
Add a signal __SIGPENDINGALL to allow computing the mask of all
currently pending signals.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 05e7a60dd7 Cygwin: add init_cygheap::compute_sigblkmask method
Add method to compute process-wide signal block mask

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 9551e617e7 Cygwin: Makefile: fix ctags --extras option
--extra is deprectated, use --extras

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen c78f149733 Cygwin: handle_sigprocmask: If new signal set is NULL, ignore "how"
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>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 25937aa1d0 Cygwin: /proc/<PID>/status: fix format specifier
The format specifier used for the signal masks is incorrectly
assuming 32 bit values.  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Takashi Yano aec053c60c Cygwin: pty: Rename some functions/variables with the name *pcon*.
- 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.
2022-03-01 22:09:01 +09:00
Corinna Vinschen 3e11a002b3 Cygwin: sysconf: _SC_TZNAME_MAX: return -1 as valid value
sysconf incorrectly sets errno to EINVAL for _SC_TZNAME_MAX.
Don't do that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 11:43:52 +01:00
Takashi Yano 1e6c51d741 Cygwin: pty: Reorganize the code path of setting up and closing pcon.
- This patch reorganizes the code path of setting-up and cleaning-up
  of the pseudo console to improve readability and maintainability
  of pty code.
2022-03-01 19:40:55 +09:00
Takashi Yano fbfea31dd9 Cygwin: pty: Avoid cutting the branch the pty master is sitting on.
- 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.
2022-03-01 19:40:46 +09:00
Mike Frysinger 644e8bba07 newlib: xstormy16: add missing string.h include
Some of these functions are using memcpy & memset from string.h but
not including the header leading to implicit declaration warnings.
2022-03-01 01:14:33 -05:00
Mike Frysinger a531ad9726 newlib: speed up targ-include setup & add error checking
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.
2022-02-28 19:07:22 -05:00
Mike Frysinger ed459780f4 libgloss: add a little build system generation documentation
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.
2022-02-28 19:05:32 -05:00
Mike Frysinger 28724b2f62 newlib: libc: move stdio multiplex logic from build to source files
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.
2022-02-28 19:04:11 -05:00
Mike Frysinger ec5ea6efae newlib: simplify header setup rules
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.
2022-02-28 19:03:57 -05:00
Takashi Yano 95a28b1f9e Cygwin: pty: Isolate CTRL_C_EVENTs between ptys.
- 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.
2022-02-28 20:25:09 +09:00
Takashi Yano 8ff9f216fd Cygwin: console: Improve the code to avoid typeahead key swapping.
- 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.
2022-02-28 20:17:12 +09:00
Takashi Yano f6db6f52ae Cygwin: pinfo: Fix exit code for non-cygwin apps which reads console.
- 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.
2022-02-28 20:10:02 +09:00
Takashi Yano 15a35758d8 Cygwin: termios: Ensure detection of GDB inferior in process_sigs().
- In some situations, some cygwin processes might wrongly identified
  as GDB inferior. This patch ensures the detection of GDB inferior.
2022-02-28 08:00:16 +09:00
Takashi Yano 33d8578feb Cygwin: termios: Add comments to the code refactored recently.
- This patch adds some comments to the source code whose intent may
  not be clear enough from the code which is refactored recently.
2022-02-27 20:50:53 +09:00
Takashi Yano d857df6f08 Cygwin: console: Correct the past fix for apps which open pty.
- 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.
2022-02-27 12:46:05 +09:00
Takashi Yano 696a713bf2 Cygwin: console: Revert experimental code mixed accidentally.
- The commit "Cygwin: console: Restore CTRL_BREAK_EVENT handling."
  was accidentally mixed with experimental code in exceptions.cc.
  Due to this, non-cygwin app receives CTRL_C_EVENT twice in the
  following scenario.
   1) Run 'sleep 10 | <non-cygwin app>'
   2) Hit Ctrl-C.
   3) The non-cygwin app receives CTRL_C_EVENT twice.
  This patch reverts the code with the problem.
2022-02-27 00:34:30 +09:00
Takashi Yano 95a60b7fdd Cygwin: console: Prevent the order of typeahead input from swapped.
- If a lot of keys are typed very quickly in the app which does
  not read console, the order of input keys in console input buffer
  occasionally swapped. Although this extremely rarely happens,
  is obviously a bug of cons_master_thread. This patch fixes the
  issue.
2022-02-26 15:59:54 +09:00
Takashi Yano e9d4341677 Cygwin: pty: Stop to send CTRL_C_EVENT if pcon activated.
- The commit "Cygwin: console: Redesign handling of special keys."
  removes special treatment for pty in with pseudo console activated,
  however, it is necessary on second thought. This is because sending
  CTRL_C_EVENT to non-cygwin apps will be done in pseudo console,
  therefore, sending it in fhandler_pty_master::write() duplicates
  that event for non-cygwin apps.
2022-02-26 15:59:32 +09:00
Takashi Yano 32401ad98e Cygwin: console: Fix issues of apps which open pty.
- After some recent changes for special keys handling break the
  apps which open pty (such as script command). If the app which
  opens pty is executed in console, the following issues occur.
    1) If the script command was started from non-cygwin shell
       (such as cmd.exe), another cygwin app started in pty slave
       cannot receive Ctrl-C.
    2) If non-cygwin app is executed in pty slave, the app which
       opened the pty (e.g. script command) crashes by Ctrl-C.
  This patch fixes these issues.
2022-02-26 15:59:20 +09:00
Mike Frysinger 69d93f3121 libgloss: iq2000: fix prototype 2022-02-25 23:08:45 -05:00