delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_RG,T_TO_NO_BRKTS_FREEMAIL |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4D995AA9.9090909@gmail.com> |
Date: | Sun, 03 Apr 2011 22:44:09 -0700 |
From: | Daniel Colascione <dan DOT colascione AT gmail DOT com> |
User-Agent: | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Utility: injob |
X-IsSubscribed: | yes |
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 |
--------------enig4C6B3EDC12BD93F9F0E9F454 Content-Type: multipart/mixed; boundary="------------020402040402000803040003" This is a multi-part message in MIME format. --------------020402040402000803040003 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Attached is a small program that runs a set of processes under an NT job object, allowing you to stop, resume, and kill them using normal Cygwin job control --- whether or not these processes are Cygwin programs. The program doesn't address every corner case, and programs run under injob might behave strangely if they use job objects themselves. Nevertheless, it suits my purposes, and it might be useful to others. --------------020402040402000803040003 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="injob.c" Content-Transfer-Encoding: base64 Content-Dis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GFuZGxlLAogICAgSEFORExF IEpvYkhhbmRsZSwKICAgIFBCT09MIFJlc3VsdAogICAgKTsKCiNkZWZpbmUg Q0hLKG9wKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBcCiAgICAoeyAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgaW50 IGNoa19yZXQ7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBcCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgZG8geyAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBcCiAgICAgICAgICAgIGNoa19yZXQgPSAob3ApOyAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgfSB3aGlsZSAo Y2hrX3JldCA9PSAtMSAmJiBlcnJubyA9PSBFSU5UUik7ICAgICAgICAgICAg ICBcCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgaWYgKGNoa19yZXQg PT0gLTEpIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBc CiAgICAgICAgICAgIGZwcmludGYgKHN0ZGVyciwgUFJHTkFNRSAiOiAiICNv cCAiOiAlc1xuIiwgICAgICAgICBcCiAgICAgICAgICAgICAgICAgICAgIHN0 cmVycm9yIChlcnJubykpOyAgICAgICAgICAgICAgICAgICAgICAgICBcCiAg ICAgICAgICAgIGdvdG8gb3V0OyAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBcCiAgICAgICAgfSAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAg ICAgY2hrX3JldDsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBcCiAgICB9KQoKI2RlZmluZSBDSEtfVzMyX0hBTkRM RShvcCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwK ICAgICh7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIFwKICAgICAgICBIQU5ETEUgY2hrX3JldCA9 IChvcCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAg ICAgICBpZiAoY2hrX3JldCA9PSBOVUxMIHx8ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIFwKICAgICAgICAgICAgY2hrX3JldCA9PSBJTlZB TElEX0hBTkRMRV9WQUxVRSkgICAgICAgICAgICAgICAgICAgIFwKICAgICAg ICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIFwKICAgICAgICAgICAgZnByaW50ZiAoc3RkZXJyLCBQ UkdOQU1FICI6ICIgI29wICI6ICVzXG4iLCAgICAgICAgIFwKICAgICAgICAg ICAgICAgICAgICAgZXJybXNnIChHZXRMYXN0RXJyb3IgKCkpKTsgICAgICAg ICAgICAgICAgIFwKICAgICAgICAgICAgZ290byBvdXQ7ICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICAgICB9ICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIFwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICAgICBjaGtfcmV0 OyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIFwKICAgIH0pCgojZGVmaW5lIENIS19XMzJfQk9PTChvcCkgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAogICAgKHsgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgXAogICAgICAgIEJPT0wgY2hrX3JldCA9IChvcCk7ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAogICAgICAgIGlmIChj aGtfcmV0ID09IEZBTFNFKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgXAogICAgICAgICAgICBmcHJpbnRmIChzdGRlcnIsIFBSR05BTUUg IjogIiAjb3AgIjogJXNcbiIsICAgICAgICAgXAogICAgICAgICAgICAgICAg ICAgICBlcnJtc2cgKEdldExhc3RFcnJvciAoKSkpOyAgICAgICAgICAgICAg ICAgXAogICAgICAgICAgICBnb3RvIG91dDsgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgXAogICAgICAgIH0gICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg XAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgXAogICAgICAgIGNoa19yZXQ7ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAog ICAgfSkKCiAgICAKI2RlZmluZSBQSVBFX1JFQUQgIDAKI2RlZmluZSBQSVBF X1dSSVRFIDEKCnN0cnVjdCBzdXNwZW5kCnsKICAgIERXT1JEICAgdGhyZWFk X2lkOwogICAgSEFORExFICB0aHJlYWQ7CiAgICAKICAgIFNMSVNUX0VOVFJZ IChzdXNwZW5kKSBlbnRyaWVzOwp9OwoKc3RhdGljIHZvaWQKdXNhZ2UoKQp7 CiAgICBmcHJpbnRmKAogICAgICAgIHN0ZG91dCwgCiAgICAgICAgUFJHTkFN RSAiIFBST0dSQU0gQVJHMSBBUkcyLi4uOiBSdW4gUFJPR1JBTSBpbiBhIGpv YiBvYmplY3RcbiIKICAgICAgICAiXG4iCiAgICAgICAgIiAgUFJP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U1RfRklSU1QgKCZzdXNw ZW5kX2xpc3RfaGVhZCk7CiAgICAgICAgU0xJU1RfUkVNT1ZFX0hFQUQgKCZz dXNwZW5kX2xpc3RfaGVhZCwgZW50cmllcyk7CgogICAgICAgIC8qIERvbid0 IGNhcmUgYWJvdXQgZmFpbHVyZXMgaGVyZS4gQmVzdCBlZmZvcnQuICovCiAg ICAgICAgUmVzdW1lVGhyZWFkIChzdXNwLT50aHJlYWQpOwogICAgICAgIENs b3NlSGFuZGxlIChzdXNwLT50aHJlYWQpOwogICAgICAgIGZyZWUgKHN1c3Ap OwogICAgfQp9CgpzdGF0aWMgQk9PTAppc190aHJlYWRfYWxyZWFkeV9zdXNw ZW5kZWQgKERXT1JEIHRocmVhZF9pZCkKewogICAgc3RydWN0IHN1c3BlbmQq IHM7CiAgICBTTElTVF9GT1JFQUNIIChzLCAmc3VzcGVuZF9saXN0X2hlYWQs IGVudHJpZXMpIHsKICAgICAgICBpZiAocy0+dGhyZWFkX2lkID09IHRocmVh ZF9pZCkgewogICAgICAgICAgICByZXR1cm4gVFJVRTsKICAgICAgICB9CiAg ICB9CgogICAgcmV0dXJuIEZBTFNFOwp9CgovKiBCcnV0ZSBmb3JjZS4gU3Vz cGVuZCB1bnRpbCB3ZSBjYW4ndCBzdXNwZW5kIGFueW1vcmUuICovCnN0YXRp YyB2b2lkCnN1c3BlbmRfYWxsX2luX2pvYiAoSEFORExFIGpvYikKewogICAg dW5zaWduZWQgbnJfc3VzcGVuZGVkOwogICAgSEFORExFIHNuYXA7CiAgICBU SFJFQURFTlRSWTMyIHRoZW50OwogICAgSEFORExFIHByb2M7CiAgICBIQU5E TEUgdGhyZWFkOwogICAgQk9PTCBwcm9jZXNzX2luX2pvYjsKICAgIHN0cnVj dCBzdXNwZW5kKiBuZXdfc3VzcCA9IE5VTEw7CiAgICB1bnNpZ25lZCB0cnlf Y291bnQgPSAxMDAwOwoKICAgIGZwcmludGYgKHN0ZGVyciwgInRyeWluIHRv IHN1c3BlbmQgYWxsIGluIGpvYlxuIik7CgogICAgZG8gewogICAgICAgIG5y X3N1c3BlbmRlZCA9IDA7CiAgICAgICAgc25hcCA9IENyZWF0ZVRvb2xoZWxw MzJTbmFwc2hvdCAoVEgzMkNTX1NOQVBUSFJFQUQsIDApOwoKICAgICAgICBp ZiAoc25hcCA9PSBOVUxMKSB7CiAgICAgICAgICAgIGdvdG8gbmV4dF9zbmFw c2hvdDsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgbWVtc2V0ICgmdGhl bnQsIDAsIHNpemVvZih0aGVudCkpOwogICAgICAgIHRoZW50LmR3U2l6ZSA9 IHNpemVvZih0aGVudCk7CiAgICAgICAgCiAgICAgICAgaWYgKFRocmVhZDMy Rmlyc3QgKHNuYXAsICZ0aGVudCkgPT0gRkFMU0UpIHsKICAgICAgICAgICAg Z290byBuZXh0X3NuYXBzaG90OwogICAgICAgIH0KICAgICAgICAKICAgICAg ICBkbyB7CiAgICAgICAgICAgIC8vIFRocmVhZDMye0ZpcnN0LE5leHR9IGlz IGFsbG93ZWQgdG8gcmV0dXJuIGEgc3RydWN0CiAgICAgICAgICAgIC8vIHNt YWxsZXIgdGhhdCB0aGUgb25lIHdlIGFza2VkIGZvciwgc28gbWFueSBzdXJl IHRoZQogICAgICAgICAgICAvLyBmaWVsZHMgd2UgdXNlZCBhcmUgaW5jbHVk ZWQgaW4gdGhpcyBzdHJ1Y3R1cmUuCiAgICAgICAgICAgIAogICAgICAgICAg ICBpZiAodGhlbnQuZHdTaXplIDwgc2l6ZW9mKERXT1JEKSo0KSB7CiAgICAg ICAgICAgICAgICBnb3RvIG5leHRfdGhyZWFkOwogICAgICAgICAgICB9Cgog ICAgICAgICAgICBwcm9jID0gTlVMTDsKICAgICAgICAgICAgdGhyZWFkID0g TlVMTDsKCiAgICAgICAgICAgIHByb2MgPSBPcGVuUHJvY2VzcyAoUFJPQ0VT U19BTExfQUNDRVNTLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IEZBTFNFIC8qZG8gbm90IGluaGVyaXQqLywKICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICB0aGVudC50aDMyT3duZXJQcm9jZXNzSUQpOwoKICAg ICAgICAgICAgaWYgKHByb2MgPT0gTlVMTCkgewogICAgICAgICAgICAgICAg Z290byBuZXh0X3RocmVhZDsKICAgICAgICAgICAgfQoKICAgICAgICAgICAg aWYgKFhJc1Byb2Nlc3NJbkpvYiAocHJvYywgam9iLCAmcHJvY2Vzc19pbl9q b2IpID09IEZBTFNFKSB7CiAgICAgICAgICAgICAgICBnb3RvIG5leHRfdGhy ZWFkOwogICAgICAgICAgICB9CiAgICAgICAgICAgIAogICAgICAgICAgICBp ZiAocHJvY2Vzc19pbl9qb2IgPT0gRkFMU0UpIHsKICAgICAgICAgICAgICAg IGdvdG8gbmV4dF90aHJlYWQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAg CiAgICAgICAgICAgIC8qIFdlIGZvdW5kIGEgdGhyZWFkIGluIGEgcHJvY2Vz cyB0aGF0J3MgaW4gb3VyIGpvYi4gIE5vdwogICAgICAgICAgICAgKiBoZXJl J3MgdGhlIE8oTl4yKSBwYXJ0IHdoZXJlIHdlIGV4YW1pbmUgb3VyIGVudGly ZSBsaXN0CiAgICAgICAgICAgICAqIHNvIGZhciB0byBtYWtlIHN1cmUgd2Ug aGF2ZW4ndCBhbHJlYWR5IG5vdGljZWQgdGhpcwogICAgICAgICAgICAgKiB0 aHJlYWQuICovCiAgICAgICAgICAgIAogICAgICAgICAgICBpZiAoaXNfdGhy ZWFkX2FscmVhZHlfc3VzcGVuZGVkICh0aGVudC50aDMyVGhyZWFkSUQpKSB7 CiAgICAgICAgICAgICAgICBnb3RvIG5leHRfdGhyZWFkOwogICAgICAgICAg ICB9CiAgICAgICAgICAgIAogICAgICAgICAgICB0aHJlYWQgPSBPcGVuVGhy ZWFkIChUSFJFQURfU1VTUEVORF9SRVNVTUUsCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIEZBTFNFIC8qZG8gbm90IGluaGVyaXQqLywKICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlbnQudGgzMlRocmVh ZElEKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIGlmICh0aHJlYWQgPT0g TlVMTCkgewogICAgICAgICAgICAgICAgZ290byBuZXh0X3RocmVhZDsKICAg ICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICAgICAgLyogV2UgZm91 bmQgYSBtYXRjaCB3ZSBkaWRuJ3Qgbm90aWNlIGJlZm9yZS4gKi8KICAgICAg ICAgICAgCiAgICAgICAgICAgIG5ld19zdXNwID0gbWFsbG9jIChzaXplb2Yo Km5ld19zdXNwKSk7CiAgICAgICAgICAgIGlmIChuZXdfc3VzcCA9PSBOVUxM KSB7CiAgICAgICAgICAgICAgICBnb3RvIG5leHRfdGhyZWFkOwogICAgICAg ICAgICB9CiAgICAgICAgICAgIAogICAgICAgICAgICBuZXdfc3VzcC0+dGhy ZWFkID0gdGhyZWFkOwogICAgICAgICAgICBuZXdfc3VzcC0+dGhyZWFkX2lk ID0gdGhlbnQudGgzMlRocmVhZElEOwogICAgICAgICAgICAKICAgICAgICAg ICAgLyogVHJ5IHRvIHN1c3BlbmQgdGhlIHRocmVhZCAqLwoKICAgICAgICAg ICAgaWYgKFN1c3BlbmRUaHJlYWQgKHRocmVhZCkgPT0gKERXT1JEKS0xKSB7 CiAgICAgICAgICAgICAgICBnb3RvIG5leHRfdGhyZWFkOwogICAgICAgICAg ICB9CiAgICAgICAgICAgIAogICAgICAgICAgICBTTElTVF9JTlNFUlRfSEVB RCAoJnN1c3BlbmRfbGlzdF9oZWFkLCBuZXdfc3VzcCwgZW50cmllcyk7CiAg ICAgICAgICAgICsrbnJfc3VzcGVuZGVkOwoKICAgICAgICAgICAgZnByaW50 ZiAoc3RkZXJyLCAiICBzdXNwZW5kZWQgdGhyZWFkcyBucl9zdXNwZW5kZWQ9 JXVcbiIsCiAgICAgICAgICAgICAgICAgICAgICh1bnNpZ25lZClucl9zdXNw ZW5kZWQpOwogICAgICAgICAgICAKICAgICAgICAgICAgdGhyZWFkID0gTlVM TDsKICAgICAgICAgICAgbmV3X3N1c3AgPSBOVUxMOwogICAgICAgICAgICAK ICAgICAgICAgIG5leHRfdGhyZWFkOgoKICAgICAgICAgICAgZnJlZSAobmV3 X3N1c3ApOwoKICAgICAgICAgICAgaWYgKHRocmVhZCAhPSBOVUxMKSB7CiAg ICAgICAgICAgICAgICBDbG9zZUhhbmRsZSAodGhyZWFkKTsKICAgICAgICAg ICAgfQoKICAgICAgICAgICAgaWYgKHByb2MgIT0gTlVMTCkgewogICAgICAg ICAgICAgICAgQ2xvc2VIYW5kbGUgKHByb2MpOwogICAgICAgICAgICB9CiAg ICAgICAgICAgIAogICAgICAgICAgICBtZW1zZXQgKCZ0aGVudCwgMCwgc2l6 ZW9mKHRoZW50KSk7CiAgICAgICAgICAgIHRoZW50LmR3U2l6ZSA9IHNpemVv Zih0aGVudCk7CiAgICAgICAgfSB3aGlsZSAoVGhyZWFkMzJOZXh0IChzbmFw LCAmdGhlbnQpKTsKICAgICAgICAKICAgICAgbmV4dF9zbmFwc2hvdDoKICAg ICAgICBpZiAoc25hcCAhPSBOVUxMKSB7CiAgICAgICAgICAgIENsb3NlSGFu ZGxlIChzbmFwKTsKICAgICAgICAgICAgc25hcCA9IE5VTEw7CiAgICAgICAg fQogICAgfSB3aGlsZSAodHJ5X2NvdW50LS0gJiYgbnJfc3VzcGVuZGVkID4g MCk7Cn0KCnN0YXRpYyB2b2lkCmR1bW15X3NpZ2hhbmRsZXIgKGludCBkdW1t eSkKe30KCnN0YXRpYyBjb25zdCBzdHJ1Y3Qgb3B0aW9uCmxvbmdvcHRzW10g PSAKewoJeyAiaGVscCIsICAgICAgMCwgMCwgJ2gnIH0sCiAgICAgICAgeyAi dmVyc2lvbiIsICAgMCwgMCwgJ1YnIH0sCgl7IDAgfQp9OwoKc3RhdGljIGlu dApjaGlsZF9tYWluIChpbnQgYXJnYywgY2hhcioqIGFyZ3YsIGludCogY2hp bGRfcGlwZSkKewogICAgaW50IHJldCA9IDE7CiAgICBzc2l6ZV90IHJyZXQ7 CiAgICBjaGFyIGJ1ZlsxXTsKICAgIGludCBjaGlsZF9zdGF0dXM7CgogICAg Q0hLIChjbG9zZSAoY2hpbGRfcGlwZVtQSVBFX1dSSVRFXSkpOwoKICAgIGRv IHsKICAgICAgICBycmV0ID0gcmVhZCAoY2hpbGRfcGlwZVtQSVBFX1JFQURd LCAmYnVmLCAxKTsKICAgIH0gd2hpbGUgKHJyZXQgPT0gLTEgJiYgZXJybm8g PT0gRUlOVFIpOwoKICAgIGlmIChycmV0ID09IDApIHsKICAgICAgICAvKiBQ YXJlbnQgZGllZCBiZWZvcmUgaXQgcmVhZGllZCB1cywgc28gZGllIGFsb25n IHdpdGggaXQuICovCiAgICAgICAgZ290byBvdXQ7CiAgICB9CgogICAgQ0hL IChjbG9zZSAoY2hpbGRfcGlwZVtQSVBFX1JFQURdKSk7CgogICAgZG8gewog ICAgICAgIHJldCA9IHNwYXdudnAgKF9QX05PV0FJVCwgYXJndlswXSwgKGNv bnN0IGNoYXIqKilhcmd2KTsKICAgIH0gd2hpbGUgKHJldCA9PSAtMSAmJiBl cnJubyA9PSBFSU5UUik7CgogICAgaWYgKHJldCA9PSAtMSkgewogICAgICAg IGZwcmludGYgKHN0ZGVyciwgUFJHTkFNRSAiOiBjb3VsZCBub3Qgc3Bhd24g XCIlc1wiOiAlc1xuIiwKICAgICAgICAgICAgICAgICBhcmd2WzBdLCBzdHJl cnJvciAoZXJybm8pKTsKICAgICAgICByZXQgPSAxMjg7CiAgICAgICAgZ290 byBvdXQ7CiAgICB9CgogICAgQ0hLICh3YWl0ICgmY2hpbGRfc3RhdHVzKSk7 CiAgICAgICAgCiAgICByZXQgPSAoIFdJRkVYSVRFRCAoY2hpbGRfc3RhdHVz KQogICAgICAgICAgICA/IFdFWElUU1RBVFVTIChjaGlsZF9zdGF0dXMpCiAg ICAgICAgICAgIDogMTI4ICsgV1RFUk1TSUcgKGNoaWxkX3N0YXR1cykgKTsK CiAgb3V0OgogICAgcmV0dXJuIHJldDsKfQoKaW50Cm1haW4gKGludCBhcmdj LCBjaGFyKiogYXJndikKewogICAgaW50IGM7CiAgICBpbnQgcmV0ID0gMTsK ICAgIEhBTkRMRSBqb2I7CiAgICBpbnQgY2hpbGRfc3RhdHVzOwogICAgc2ln c2V0X3Qgd2FpdG1hc2s7CiAgICBzaWdzZXRfdCBvcmlnbWFzazsKICAgIHBp ZF90IGNoaWxkX3BpZDsKICAgIGludCBjaGlsZF9waXBlWzJdOwogICAgaW50 IHNpZzsKICAgIERXT1JEIGNoaWxkX3czMl9waWQ7CiAgICBIQU5ETEUgY2hp bGRfcHJvY19oYW5kbGU7CiAgICBKT0JPQkpFQ1RfQkFTSUNfTElNSVRfSU5G T1JNQVRJT04gam9iX2Jhc2ljX2xpbWl0czsKICAgIEhBTkRMRSBrZXJuZWwz MmRsbDsKCiAgICAvKiBJbml0aWFsaXplICovCgogICAgd2hpbGUgKChjID0g Z2V0b3B0X2xvbmcoYXJnYywgYXJndiwgIlZoIiwgbG9uZ29wdHMsIDApKSAh PSAtMSkgewogICAgICAgIHN3aXRjaChjKSB7CiAgICAgICAgICAgIGNhc2Ug J2gnOgogICAgICAgICAgICAgICAgdXNhZ2UoKTsKICAgICAgICAgICAgICAg IHJldCAgPSAwOwogICAgICAgICAgICAgICAgZ290byBvdXQ7CiAgICAgICAg ICAgIGNhc2UgJ1YnOgogICAgICAgICAgICAgICAgdmVyc2luZm8gKCk7CiAg ICAgICAgICAgICAgICByZXQgPSAwOwogICAgICAgICAgICAgICAgZ290byBv dXQ7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBmcHJp bnRmKHN0ZGVyciwgUFJHTkFNRSAiOiB1c2UgLS1oZWxwIGZvciB1c2FnZVxu Iik7CiAgICAgICAgICAgICAgICBnb3RvIG91dDsKICAgICAgICB9CiAgIC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AgICAgICAgIGdvdG8g ZG9uZTsKICAgICAgICAgICAgY2FzZSBTSUdURVJNOgogICAgICAgICAgICBj YXNlIFNJR0lOVDoKICAgICAgICAgICAgICAgIC8qIFdlIHdlcmUgYXNrZWQg dG8gcXVpdC4gIEtpbGwgZXZlcnl0aGluZyBpbiB0aGUgam9iLiAqLwogICAg ICAgICAgICAgICAgQ0hLX1czMl9CT09MIChUZXJtaW5hdGVKb2JPYmplY3Qg KGpvYiwgMSkpOwogICAgICAgICAgICAgICAgZ290byBkb25lOwogICAgICAg ICAgICBjYXNlIFNJR1RTVFA6CiAgICAgICAgICAgICAgICBzdXNwZW5kX2Fs bF9pbl9qb2IgKGpvYik7CiAgICAgICAgICAgICAgICByYWlzZSAoU0lHU1RP UCk7CiAgICAgICAgICAgICAgICByZXN1bWVfYWxsICgpOwogICAgICAgICAg ICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAg ICAgICBmcHJpbnRmIChzdGRlcnIsIFBSR05BTUUgIjogdW5leHBlY3RlZCBz aWduYWwgJWQ6ICVzXG4iLAogICAgICAgICAgICAgICAgICAgICAgICAgc2ln LCBzdHJlcnJvciAoZXJybm8pKTsKICAgICAgICAgICAgICAgIGdvdG8gb3V0 OwogICAgICAgIH0KICAgIH0KCiAgZG9uZToKCiAgICBDSEsgKHdhaXQgKCZj aGlsZF9zdGF0dXMpKTsKICAgICAgICAKICAgIHJldCA9ICggV0lGRVhJVEVE IChjaGlsZF9zdGF0dXMpCiAgICAgICAgICAgID8gV0VYSVRTVEFUVVMgKGNo aWxkX3N0YXR1cykKICAgICAgICAgICAgOiAxMjggKyBXVEVSTVNJRyAoY2hp bGRfc3RhdHVzKSApOwogICAgCiAgICBvdXQ6CiAgICByZXR1cm4gcmV0Owp9 Cg== --------------020402040402000803040003-- --------------enig4C6B3EDC12BD93F9F0E9F454 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk2ZWq0ACgkQ17c2LVA10Vtt+ACg18PEma7rMk746bwjaHhwrdB1 ly4An06r2hKLAcKvHMDM4JFKIjI7vnXk =lbJB -----END PGP SIGNATURE----- --------------enig4C6B3EDC12BD93F9F0E9F454--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |