delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/03/16/12:51:44

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:content-type:mime-version:subject:from
:in-reply-to:date:content-transfer-encoding:message-id
:references:to; q=dns; s=default; b=GI9FMuNmwCAYHG4GQnI3e/6pOc/a
leH0Gu8rrN9rQiDnleDJfZVRShFMFLIytic9bhwPZQN+yKBkJxHMsOSlK+lEaBxD
2iYEAVE2Qd8goofsTRTKhLkZzliEDt/OyfD8oIt+BnsoGNZQI1Qb8Hpj1piAKuZ3
HarxPaX2Pnv/NWw=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:content-type:mime-version:subject:from
:in-reply-to:date:content-transfer-encoding:message-id
:references:to; s=default; bh=RyBOxWWWVUZCP4K1+Y1IKklv3rs=; b=N5
NcvSsIEs1BVgwtqaJorcNrM8+8aSRNsepB2JxxdKTVPJk6AthH4SjHW7l1xcvf7g
TOSdLJIwgiHv57Mb0MdyFMl1LaMhNA0Dz5g6kRVily+wpStuV7aK+IUdlr8m1Go5
Gq5PEs08VbExa58Fb1YJvyIfww2WMu6lBcvob9TQY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.2 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=UD:DLL, sk:ler762, ler762 AT gmail DOT com, U*ler762
X-HELO: etr-usa.com
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
Subject: Re: ctrl-c doesn't reliably kill ping
From: Warren Young <wyml AT etr-usa DOT com>
In-Reply-To: <CAD8GWstL-rUm9=q8tpReiiHm8Tmm94Caq7jQyszZ02Tw=EN_TQ@mail.gmail.com>
Date: Wed, 16 Mar 2016 10:50:47 -0600
Message-Id: <8D39BB0F-A716-4F56-AF2D-D6C928266F5A@etr-usa.com>
References: <56E6F25A DOT 7070000 AT gmx DOT de> <56E75B3E DOT 7020102 AT farance DOT com> <CAD8GWstL-rUm9=q8tpReiiHm8Tmm94Caq7jQyszZ02Tw=EN_TQ AT mail DOT gmail DOT com>
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id u2GGpejP023688

On Mar 16, 2016, at 10:07 AM, Lee <ler762 AT gmail DOT 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019