Re: [PATCH] regtool: allow /proc/registry{,32,64}/ registry path prefix

2019-11-13 Thread Corinna Vinschen
Hi Brian,

On Nov 11 10:29, Brian Inglis wrote:
> The user can supply the registry path prefix /proc/registry{,32,64}/ to
> use path completion.

The git commit message does not outline why you're changing the example,

Given that the example doesn't use /proc/registry anyway, what's the
reasoning?  This should either be a patch on its own or at least this
should be mentioned in the commit message.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] regtool: Ignore /proc/registry{,32,64}/ prefix, with forward or backslashes, allowing path completion

2019-11-13 Thread Corinna Vinschen
On Nov 11 13:47, Brian Inglis wrote:
> On 2019-11-11 09:28, Corinna Vinschen wrote:
> > Ok, we can add something to the help text, but the text still sounds
> > confusing, even the altenative one.  I think the reason is the negative
> > expression "ignore" here.  Why not express this in a positive way like
> > this:
> > 
> >   "Use the /proc/registry{,32,64}/ registry path prefix to utilize path
> >completion."
> > 
> > Something like that anyway.
> 
> Maybe something may be misinterpreted from your consideration of International
> English wording that is not even considered in my native English; "is ignored"
> is passive voice but not negative in English, and neither does it appear to be
> so in Deutsch (via Google): "Zur Unterstützung der Pfadvervollständigung wird
> das Schlüsselnamenpräfix /proc/registry{,32,64}/ ignoriert."

Probably I phrased this wrong.  I was not talking about negative
connotation, but about using a negating expression.  Not doing something
vs. doing the other.   To a non-developer it may be pretty unclear
what's the deal with "ignoring a path prefix".  I think a simpler,
positive (non-negating) expression may be clearer, that's all.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] Cygwin: pty: Use redraw screen instead of clear screen.

2019-11-13 Thread Corinna Vinschen
On Nov 12 22:00, Takashi Yano wrote:
> - Previously, pty cleared screen at startup for synchronization
>   between the real screen and console screen buffer for pseudo
>   console. With this patch, instead of clearing screen, the screen
>   is redrawn when the first native program is executed after pty
>   is created. In other words, synchronization is deferred until
>   the native app is executed. Moreover, this realizes excluding
>   $TERM dependent code.
> ---
>  winsup/cygwin/fhandler_tty.cc | 30 --
>  winsup/cygwin/tty.cc  |  2 +-
>  winsup/cygwin/tty.h   |  2 +-
>  3 files changed, 18 insertions(+), 16 deletions(-)

Great!  Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] Cygwin: console: Revise the code checking if the console is legacy.

2019-11-13 Thread Corinna Vinschen
On Nov 13 03:04, Takashi Yano wrote:
> - Accessing shared_console_info before initializing causes access
>   violation in checking if the console is legacy mode. This patch
>   fixes this issue. This solves the problem reported in:
>   https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00099.html
> ---
>  winsup/cygwin/fhandler_console.cc | 29 +++--
>  1 file changed, 15 insertions(+), 14 deletions(-)

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: cygrunsrv patch

2019-11-13 Thread Corinna Vinschen
On Nov 12 19:41, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin-patches wrote:
> Hi,
> 
> Looks like I finally prepared a patch for cygrunsrv that I mentioned as an 
> added feature way back in Feb (I did not need to come around to that since 
> then):
> 
> https://cygwin.com/ml/cygwin/2019-02/msg00173.html
> 
> But the GIT URL given in the message does not seem to work for me:
> 
> https://cygwin.com/git/?p=cygwin-apps/cygrunsrv.git

This is the URL to the GUI, sorry.  The URL to the repo itself
is the same, just without the "?p=":

  https://cygwin.com/git/cygwin-apps/cygrunsrv.git

Patches to cygrunsrv should be sent to the cygwin-apps ML, though, not
to cygwin-patches, but given the low traffic here anyway, that's ok,
too.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] regtool: allow /proc/registry{,32,64}/ registry path prefix

2019-11-13 Thread Corinna Vinschen
On Nov 13 09:46, Corinna Vinschen wrote:
> Hi Brian,
> 
> On Nov 11 10:29, Brian Inglis wrote:
> > The user can supply the registry path prefix /proc/registry{,32,64}/ to
> > use path completion.
> 
> The git commit message does not outline why you're changing the example,
> 
> Given that the example doesn't use /proc/registry anyway, what's the
> reasoning?  This should either be a patch on its own or at least this
> should be mentioned in the commit message.

Sigh, I accidentally pushed this patch as is.  Never mind then.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] Cygwin: pty: Use redraw screen instead of clear screen.

2019-11-13 Thread Takashi Yano
On Wed, 13 Nov 2019 10:18:35 +0100
Corinna Vinschen wrote:
> On Nov 12 22:00, Takashi Yano wrote:
> > - Previously, pty cleared screen at startup for synchronization
> >   between the real screen and console screen buffer for pseudo
> >   console. With this patch, instead of clearing screen, the screen
> >   is redrawn when the first native program is executed after pty
> >   is created. In other words, synchronization is deferred until
> >   the native app is executed. Moreover, this realizes excluding
> >   $TERM dependent code.
> > ---
> >  winsup/cygwin/fhandler_tty.cc | 30 --
> >  winsup/cygwin/tty.cc  |  2 +-
> >  winsup/cygwin/tty.h   |  2 +-
> >  3 files changed, 18 insertions(+), 16 deletions(-)
> 
> Great!  Pushed.

I have found the cursor position is broken even with this patch
if the following steps are executed.

1) start mintty
2) netsh
3) quit from netsh
4) start gnu screen
5) quit from gnu screen
6) netsh
7) winhttp show proxy

I will submit a patch for this issue.

-- 
Takashi Yano 


[PATCH] Cygwin: pty: Trigger redraw screen if ESC[?3h or ESC[?3l is sent.

2019-11-13 Thread Takashi Yano
- Pseudo console clears console screen buffer if ESC[?3h or ESC[?3l
  is sent. However, xterm/vt100 does not clear screen. This cause
  mismatch between real screen and console screen buffer. Therefore,
  this patch triggers redraw screen in that situation so that the
  synchronization is done on the next execution of native app.
  This solves the problem reported in:
  https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00116.html
---
 winsup/cygwin/fhandler_tty.cc | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index e02a8f43b..f9c7c3ade 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1255,6 +1255,28 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const 
char *ptr, size_t len)
   memmove (p0, p0+4, nlen - (p0+4 - buf));
   nlen -= 4;
 }
+
+  /* If the ESC sequence ESC[?3h or ESC[?3l which clears console screen
+ buffer is pushed, set need_redraw_screen to trigger redraw screen. */
+  p0 = buf;
+  while ((p0 = (char *) memmem (p0, nlen - (p0 - buf), "\033[?", 3)))
+{
+  p0 += 3;
+  while (p0 < buf + nlen && *p0 != 'h' && *p0 != 'l')
+   {
+ int arg = 0;
+ while (p0 < buf + nlen && isdigit (*p0))
+   arg = arg * 10 + (*p0 ++) - '0';
+ if (arg == 3)
+   get_ttyp ()->need_redraw_screen = true;
+ if (p0 < buf + nlen && *p0 == ';')
+   p0 ++;
+   }
+  p0 ++;
+  if (p0 >= buf + nlen)
+   break;
+}
+
   DWORD dwMode, flags;
   flags = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
   GetConsoleMode (get_output_handle (), &dwMode);
-- 
2.21.0



Re: [PATCH] regtool: allow /proc/registry{,32,64}/ registry path prefix

2019-11-13 Thread Brian Inglis
On 2019-11-13 02:38, Corinna Vinschen wrote:
> On Nov 13 09:46, Corinna Vinschen wrote:
>> On Nov 11 10:29, Brian Inglis wrote:
>>> The user can supply the registry path prefix /proc/registry{,32,64}/ to
>>> use path completion.
>> The git commit message does not outline why you're changing the example,
>> Given that the example doesn't use /proc/registry anyway, what's the
>> reasoning?  This should either be a patch on its own or at least this
>> should be mentioned in the commit message.

I explained in my earlier reply that it showed forward slashes and fit the doc
pages better; adding /proc/registry/... would be difficult to fit in the width!

> Sigh, I accidentally pushed this patch as is.  Never mind then.

In my earlier reply I said something which could be added to the commit message
with an --amend, if you wish:

Change doc example to be consistent and a better choice to show
forward slashes, and fit the width of the docs.

New COMMIT_MSG:
regtool: allow /proc/registry{,32,64}/ registry path prefix

The user can supply the registry path prefix /proc/registry{,32,64}/
to use path completion.
Change doc example to be consistent and a better choice to show
forward slashes, and fit the width of the docs.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.


[PATCH] cygrunsrv: Added options -T and -X; fixed a couple minor issues

2019-11-13 Thread Anton Lavrentiev via cygwin-patches
1. https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00107.html
2. Fixed an issue with "premature exit" error message printed if service is 
stopped from SCM by an operator
3. Fixed a potential issue with reporting 0 exit code when a service being 
stopped did not actually stop
---
 ChangeLog|   6 +++
 cygrunsrv.cc | 125 +--
 cygrunsrv.h  |   5 +++
 utils.cc |   8 
 utils.h  |   5 +++
 5 files changed, 115 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b68ff6b..5466c69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-12  Anton Lavrentiev 
+
+* Added the -T (for timeout) and the -X (for stop timeout) options
+* cygrunsrv.cc:  issue no "premature exit" error when stopped by SCM
+(and daemon catches the internal signal then exits)
+
 2015-01-28  Corinna Vinschen 
 
* cygrunsrv.README: Fix typo.
diff --git a/cygrunsrv.cc b/cygrunsrv.cc
index adb6ad3..31a5efd 100644
--- a/cygrunsrv.cc
+++ b/cygrunsrv.cc
@@ -82,6 +82,8 @@ struct option longopts[] = {
   { "shutdown", no_argument, NULL, 'o' },
   { "interactive", no_argument, NULL, 'i' },
   { "nohide", no_argument, NULL, 'j' },
+  { "timeout", required_argument, NULL, 'T'},
+  { "stop-timeout", required_argument, NULL, 'X'},
   { "verbose", no_argument, NULL, 'V' },
   { "help", no_argument, NULL, 'h' },
   { "version", no_argument, NULL, 'v' },
@@ -116,6 +118,8 @@ const char *opts = "I:"
   "n"
   "i"
   "j"
+  "T:"
+  "X:"
   "V"
   "h"
   "v";
@@ -131,6 +135,8 @@ DWORD preshutdown;
 DWORD shutdown;
 DWORD interactive;
 DWORD showcons;
+DWORD timeout = SERVICE_TMO;
+DWORD x_timeout = SERVICE_TMO;
 
 DWORD shutting_down = 0;
 static char service_main_exitval = 1;
@@ -245,7 +251,8 @@ install_registry_keys (const char *name, const char *desc, 
const char *path,
   const char *in_stdout, const char *in_stderr,
   const char *in_pidfile, DWORD neverexits,
   DWORD preshutdown, DWORD shutdown,
-  DWORD interactive, DWORD showcons)
+  DWORD interactive, DWORD showcons,
+  DWORD timeout, DWORD x_timeout)
 {
   HKEY srv_key = NULL;
   HKEY env_key = NULL;
@@ -358,6 +365,17 @@ install_registry_keys (const char *name, const char *desc, 
const char *path,
  (const BYTE *) &showcons,
  sizeof(DWORD))) != ERROR_SUCCESS)
   err_out_set_error (RegSetValueEx, ret);
+  if (timeout)
+if ((ret = RegSetValueEx (srv_key, PARAM_TIMEOUT, 0, REG_DWORD,
+  (const BYTE *) &timeout,
+  sizeof(DWORD))) != ERROR_SUCCESS)
+  err_out_set_error(RegSetValueEx, ret);
+  if (x_timeout)
+if ((ret = RegSetValueEx (srv_key, PARAM_X_TIMEOUT, 0, REG_DWORD,
+  (const BYTE *) &x_timeout,
+  sizeof(DWORD))) != ERROR_SUCCESS)
+  err_out_set_error(RegSetValueEx, ret);
+
   RegFlushKey (srv_key);
 
 out:
@@ -432,7 +450,8 @@ get_reg_entries (const char *name, HKEY hklm, char *&path, 
char *&args,
 char *&stdin_path, char *&stdout_path, char *&stderr_path,
 char *&pidfile_path, DWORD *neverexits_p,
 DWORD *preshutdown_p, DWORD *shutdown_p,
-DWORD *interactive_p, DWORD *showcons_p)
+DWORD *interactive_p, DWORD *showcons_p,
+DWORD *timeout_p, DWORD *x_timeout_p)
 {
   HKEY srv_key = NULL;
   HKEY env_key = NULL;
@@ -500,6 +519,16 @@ get_reg_entries (const char *name, HKEY hklm, char *&path, 
char *&args,
   (BYTE *) showcons_p,
   (size = sizeof(*showcons_p), &size)) != ERROR_SUCCESS)
 *showcons_p = 0;  // the default
+  /* Get (optional) timeout. */
+  if (RegQueryValueEx (srv_key, PARAM_TIMEOUT, 0, &type,
+  (BYTE *) timeout_p,
+  (size = sizeof(*timeout_p), &size)) != ERROR_SUCCESS)
+*timeout_p = SERVICE_TMO;  // the default
+  /* Get (optional) stop timeout. */
+  if (RegQueryValueEx (srv_key, PARAM_X_TIMEOUT, 0, &type,
+  (BYTE *) x_timeout_p,
+  (size = sizeof(*x_timeout_p), &size)) != ERROR_SUCCESS)
+*x_timeout_p = *timeout_p;  // the default is same as timeout
   /* Get (optional) stdin/stdout/stderr redirection files. */
   if ((ret = get_opt_string_entry (srv_key, PARAM_STDIN, stdin_path)))
 goto out;
@@ -511,7 +540,7 @@ get_reg_entries (const char *name, HKEY hklm, char *&path, 
char *&args,
 goto out;
   if ((ret = get_opt_string_entry (srv_key, PARAM_STDERR, stderr_path)))
 goto out;
-  else if (reeval_io_path (STDERR_FILENO, stderr_path, name))
+  else if ((ret = reeval_io_path(STDERR_FILENO, stderr_path, name)))
 goto out;
   /* Get (optional) environment strings. */
   strcat (strcat (param_key, "\\"), PARAM_ENVIRON)