Re: [Openvpn-devel] Adding a ctrl-C handler in windows

2015-11-09 Thread Selva Nair
Hi,

On Mon, Nov 9, 2015 at 1:04 PM, James Yonan  wrote:
>>> I plan to add a control-C handler in win32.c. The handler will simply
>>> map it to SIGTERM. Is there any particular reason why control-C is not
>>> currently handled?
>>
>> Hi,
>>
>> I forwarded this email to James - he might have a clue.
>
> Currently the Windows implementation, when running in console mode, uses
> function keys to trigger various Unix signals (see win32_signal_get()
> function in win32.c).
>
> The current code looks like this:
>
>switch (win32_keyboard_get (ws))
>  {
>  case 0x3B: /* F1 -> USR1 */
>ret = SIGUSR1;
>break;
>  case 0x3C: /* F2 -> USR2 */
>ret = SIGUSR2;
>break;
>  case 0x3D: /* F3 -> HUP */
>ret = SIGHUP;
>break;
>  case 0x3E: /* F4 -> TERM */
>ret = SIGTERM;
>break;
>  }
>
>
> It's probably okay to just make CTRL-c generate a SIGTERM as F4 is
> already doing.
>
> James

Thanks for the comment.

In the interactive mode, the console is opened with no
ENABLE_PROCESSED_INPUT so ctrl-C will be delivered as key-board input
and could be handled just like F4.

With nssm, the console is shared with nssm, so ctrl-C is delivered as
a signal. I'll send a patch handling both cases.

Selva



Re: [Openvpn-devel] Adding a ctrl-C handler in windows

2015-11-09 Thread James Yonan

On 09/11/2015 00:38, Samuli Seppänen wrote:



Hi,

I plan to add a control-C handler in win32.c. The handler will simply
map it to SIGTERM. Is there any particular reason why control-C is not
currently handled?


Hi,

I forwarded this email to James - he might have a clue.


Currently the Windows implementation, when running in console mode, uses 
function keys to trigger various Unix signals (see win32_signal_get() 
function in win32.c).


The current code looks like this:

  switch (win32_keyboard_get (ws))
{
case 0x3B: /* F1 -> USR1 */
  ret = SIGUSR1;
  break;
case 0x3C: /* F2 -> USR2 */
  ret = SIGUSR2;
  break;
case 0x3D: /* F3 -> HUP */
  ret = SIGHUP;
  break;
case 0x3E: /* F4 -> TERM */
  ret = SIGTERM;
  break;
}


It's probably okay to just make CTRL-c generate a SIGTERM as F4 is 
already doing.


James



Re: [Openvpn-devel] Adding a ctrl-C handler in windows

2015-11-09 Thread Samuli Seppänen



Hi,

I plan to add a control-C handler in win32.c. The handler will simply
map it to SIGTERM. Is there any particular reason why control-C is not
currently handled?


Hi,

I forwarded this email to James - he might have a clue.

Samuli




[Openvpn-devel] Adding a ctrl-C handler in windows

2015-11-07 Thread Selva Nair
Hi,

I plan to add a control-C handler in win32.c. The handler will simply
map it to SIGTERM. Is there any particular reason why control-C is not
currently handled?

We need this functionality to use nssm properly. When
openvpn is started by nssm, the service has no good ways of
gracefully terminating the process. "nssm stop service-name" can send
control-C but that is not handled by openvpn. So the default handler
catches the signal and just kills the process -- thus the MI or the logs
get no reports of the exit, no exit-notify to the remote are
generated etc..

Hope I'm not missing some obvious ways to correctly terminate the
process from nssm.

Thanks,

Selva