This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ctrl-c doesn't reliably kill ping


On Mar 16, 2016, at 10:07 AM, Lee <ler762@gmail.com> wrote:
> 
> The last time I tried the cygwin ping program it didn't return a
> failure status

It does if you donât Ctrl-C out of it.  So, if youâre using it from a script, you just ask for one packet:

    # ping does.not.exist 1 1
    ping: unknown host does.not.exist
    # echo $?
    1

Note my fine new # prompt, indicating an admin shell, which has been required for Cygwin ping from the very beginning[1] due to the restrictions on raw sockets added in Windows XP SP2.  Windows ping gets around this by special dispensation of the kernel.[2]

If you want to say Cygwin ping is âuselessâ because of that, blame Microsoft for not allowing ICMP raw sockets for normal users [3] or for not reinventing suid bits correctly.  (UAC = not correct.)

Older Linuxes and some modern Unixes set the suid bit on the ping program to get around this, and newer Linuxes use getcap/setcap to give the ping program the right to use raw sockets so they donât need u+s.[4]


[1] https://cygwin.com/ml/cygwin-apps/2005-01/msg00124.html
[2] It loads IPHLPAPI.DLL at run time in order to call IcmpSendEcho()
[3] https://goo.gl/o25d6U
[4] http://linux.die.net/man/8/setcap
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]