Commit Graph

20556 Commits

Author SHA1 Message Date
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
Mike Frysinger 7f674bb4da libgloss: switch to AM_PROG_AR
Now that we require Automake 1.15, we can use this macro rather than
set the tool up ourselves.  The current code doesn't properly search
for a prefixed ar tool as-is.
2022-02-25 23:07:20 -05:00
Mike Frysinger 8343db918f newlib: libc: move configure into top-level
This kills off the last configure script under libc/ and folds it
into the top newlib configure script.  The a lot of the logic was
already in the top configure script, so move what's left into a
libc/acinclude.m4 file.
2022-02-25 13:52:48 -05:00
Takashi Yano 3a6b11c697 Cygwin: pinfo: Fix exit code when non-cygwin app exits by Ctrl-C.
- Previously, if non-cygwin app exits by Ctrl-C, exit code was
  0x00007f00. With this patch, the exit code will be 0x00000002,
  which means process exited by SIGINT.
2022-02-25 17:29:28 +09:00
Mike Frysinger 85f2dca52d newlib: add silent rules support to top-level rules 2022-02-24 19:14:12 -05:00
Mike Frysinger e56bdf902b libgloss: document & localize custom multi-do rule
The multi-build.in file in libgloss duplicates common multilib logic
in the root source tree.  Document it a bit, and rename the rule so
it doesn't clash with the common multi-do rule.  This will let us use
them in the same makefile so we can merge aarch64/ & arm/ up (as the
only targets that use this local multi-build.in atm).
2022-02-24 19:12:45 -05:00
Mike Frysinger 15d7e0d417 libgloss: finish migration to AM_PROG_AS
When merging iq2000 up a level, it included a partial conversion to
AM_PROG_AS in the common directory.  Finish it for all directories
to kill off the custom LIB_AM_PROG_AS which we no longer need since
we require Automake 1.15 now.
2022-02-24 19:10:39 -05:00
Mike Frysinger 7edb25725d libgloss: switch to standard AC_PROG_CC
Now that we use AC_NO_EXECUTABLES, and we require a recent version of
autoconf, we don't need to define our own copies of these macros.  So
switch to the standard AC_PROG_CC.
2022-02-24 19:06:21 -05:00
Takashi Yano 5c4a0824e7 Cygwin: console: Restore CTRL_BREAK_EVENT handling.
- The recent change by the commit "Cygwin: console: Redesign handling
  of special keys." breaks the handling of CTRL_BREAK_EVENT. The login
  shell in console exits on Ctrl-Break key. This patch fixes the issue.
2022-02-24 17:35:21 +09:00
Mike Frysinger acf642177b newlib: fix multilib libg.a parallel builds
I split libg.a out into a sep target from libc.a for the main dir in
commit f2b053f49e ("newlib: separate out
libg from libc"), but missed the multilib dirs.  That leads to an
uncommon parallel build failure:
- libc.a rule runs & finishes
- $(BUILD_MULTISUBDIR)/libc.a rule runs
  -> failure due to libg.a not yet existing
- libg.a rule runs & finishes

Split the multilib libg rule out from libc too so it can depend on the
main libg directly and avoid this race.
2022-02-23 22:01:05 -05:00
Mike Frysinger 5ad394510b newlib: libm: workaround ar duplicate member behavior
GNU ar has undocumented behavior where it doesn't dedupe its inputs if
they're all on the same command line, so we have to dedupe ourselves.
2022-02-23 20:07:10 -05:00
Mike Frysinger 8d75828378 libgloss: merge sparc configure script up a level
Move the minor sparc-specific logic to a dedicated variable so we can
merge its configure logic up a level.
2022-02-23 19:44:10 -05:00
Takashi Yano 2f2b915505 Cygwin: pty, console: Add a workaround for GDB SIGINT handling.
- The inferior of the GDB cannot be continued after SIGINT even
  though nopass option is set. This seems because cygwin GDB does
  not support hooking cygwin signal. Therefore, a workaround for
  GDB is added. With this patch, only CTRL_C_EVENT is sent to the
  GDB inferior by Ctrl-C and sending SIGINT is omitted. Note that
  "handle SIGINT (no)pass" command does not take effect even with
  or without this patch.
2022-02-24 02:17:32 +09:00
Takashi Yano d2b14c303c Cygwin: console: Redesign handling of special keys.
- This patch rearranges the cooperation between cons_master_thread,
  line_edit, and ctrl_c_handler so that only one of them operates
  at the same time. Since these handle Ctrl-C individually, so the
  signal may be sent multiple times to the process. This patch fixes
  the issue.
2022-02-24 01:38:08 +09:00
Mike Frysinger 4ed502ba02 libgloss: enable maintainer mode support
Use AM_MAINTAINER_MODE so devs have to opt-in to automatic rebuilds
of autotools.  This matches what newlib (and most every other GNU
toolchain package) does with automake.
2022-02-22 17:09:16 -05:00
Corinna Vinschen f2dc492df0 Cygwin: unlink: filter out virtual files and devices early on
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-22 13:33:06 +01:00
Johannes Schindelin 4ec08891a0 Cygwin: Implicitly support the /dev/fd symlink and friends
Bash has a very convenient feature that is called process substitution
(e.g. `diff -u <(seq 0 10) <(seq 1 11)`). To make this work, Bash
requires the `/dev/fd` symlink to exist, and Cygwin therefore creates
this symlink (together with the `stdin`, `stdout` and `stderr` ones)
upon start-up.

This strategy is incompatible with the idea of providing a subset of
Cygwin in a `.zip` file (because there is no standard way to represent
symlinks in `.zip` files, and besides, older Windows versions would
potentially lack support for them anyway).

That type of `.zip` file is what Git for Windows wants to use, though,
bundling a minimal subset for third-party applications in MinGit (see
https://github.com/git-for-windows/git/wiki/MinGit for details).

Let's side-step this problem completely by creating those symlinks
implicitly, similar to the way `/dev/` is populated with special
devices.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-02-22 13:33:00 +01:00
Corinna Vinschen 8bb6821c7a Cygwin: Adjust path to newlib libc.a, too
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-22 12:49:33 +01:00
Jon Turney 56ec1fcb0d Cygwin: Adjust path to newlib libm.a in builddir
Adjust path to newlib libm.a in builddir, changed by ac9f8c46
2022-02-22 12:49:33 +01:00
Matt Joyce 44b60f0c4b Make __sdidinit unused
Remove dependency on __sdidinit member of struct _reent to check
object initialization. Like __sdidinit, the __cleanup member of
struct _reent is initialized in the __sinit() function. Checking
initialization against __cleanup serves the same purpose and will
reduce overhead in the __sfp() function in a follow up patch.
2022-02-22 12:38:46 +01:00
Takashi Yano 054b00d96a Cygwin: pty: Encapsulate pty code in tty::setpgid().
- This patch hides complex pty codes in tty::setpgid() to transfer
  input into the class fhandler_pty_slave by encapsulating it.
2022-02-22 07:33:09 +09:00
Takashi Yano 0ddf19d6ca Cygwin: pty, console: Fix handle leak which occurs on exec() error.
- This patch fixes the handle leak which occurs when exec() fails
  with an error. The duplicated handles will be closed when the
  exec'ed process is terminated. However, if exec() fails, the code
  path does not reach to the code closing the duplicated handles.
  To implement this fix more appropriately, the setup, cleanup and
  closing pty codes which was previously located in spawn.cc are
  encapsulated into the fhandler_pty_slave class functions.
2022-02-22 07:26:34 +09:00
Takashi Yano fc26624377 Cygwin: console: Call fix_tab_position() only if having broken tabs.
- Calling fix_tab_position() is necessary in Windows 10 with xterm
  compatible mode enabled, because it has a problem that the tab
  positions will be broken when the window size is changed. Fortunately,
  this problem has been fixed in Windows 11. Therefore, with this patch,
  necessity of fix_tab_position() call is determined by referring to
  wincap.has_con_broken_tabs(), which is recently introduced.
2022-02-20 19:22:09 +09:00