delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/01/29/18:50:13

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC17A3858422
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1675036164;
bh=NW49FUEHZeMDXXtYN8HBIySKYHD2143EnVGqn76nno8=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=KiqXFgsvKnHRlcEo6yPgrtY+3ZhMSsa3scf8wDkNlRjR7dyT/PTJRKoseAnJAtHVL
8Y6WJa0H5ZcoO1JaUvjKJ1l8EtIrYYuMfnrNYo3MhN+4Rlv//J1FQ2FGbaSzaCCr9v
Kc6kJ69VAT85QXmzpFQCE3IoLOK1sIeK2uHosd+c=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59D483858D32
X-Authority-Analysis: v=2.4 cv=VbHkgXl9 c=1 sm=1 tr=0 ts=63d705dd
a=oHm12aVswOWz6TMtn9zYKg==:117 a=oHm12aVswOWz6TMtn9zYKg==:17
a=IkcTkHD0fZMA:10 a=xEtqiN7rneSloUyuQzcA:9 a=QEXdDO2ut3YA:10
Message-ID: <ad5f00c1-2924-b4dd-4f6d-259f40c911e9@Shaw.ca>
Date: Sun, 29 Jan 2023 16:48:44 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Subject: Re: BUG: Log on Scheduled Task invisible/empty window blocks input
To: cygwin AT cygwin DOT com
References: <CAGJ7yHC1UxsYeV9dM03+CJiHYyj85opu8yt7tzCzQ9qE8OL4GA AT mail DOT gmail DOT com>
<3bafc985-e382-5b31-bca5-3556ca6e4e40 AT Shaw DOT ca>
<CAGJ7yHDge+-xe-zTjcCXmRNus8qFOo6m0smbHs8Z=ZHPwcdwEg AT mail DOT gmail DOT com>
Organization: Inglis
In-Reply-To: <CAGJ7yHDge+-xe-zTjcCXmRNus8qFOo6m0smbHs8Z=ZHPwcdwEg@mail.gmail.com>
X-CMAE-Envelope: MS4xfHNWeAr15+q7VeFBv2aGe9NVcNqpkCaiDLEKnoBDzxeLvPBMp+pwNWqIVmxvNLb4Wy++CQaKrTYGIa0BSg6CKSviCKi2kyrlL4r3+HvBzo4WXHbujc9X
f26GIDwG2ykbN9zujE5jKdOvRrYyzwee+BiLSeCL4OqglMCErKM2deZJPzSRmCK7wBxI+cFABZh26v7HCsFzigZnYsldJBwJsog=
X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Brian Inglis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Brian Inglis <Brian DOT Inglis AT Shaw DOT ca>, Ross Patterson <me AT rpatterson DOT net>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 30TNnpC7023478

On 2023-01-29 15:55, Ross Patterson wrote:
>> dash (or bash if required) native path with WD /var/log/ native path e.g.
>> %CYGWIN_ROOT%\bin\dash /usr/local/bin/....sh WD %CYGWIN_ROOT%\var\log

> I'm not understanding the use of `WD` here, can you clarify/elaborate?

Working Directory entry

> At any rate, I forgot to mention that I also tried adding output
> redirection to the end of the action's ""Add arguments (optional)" and
> did so in various combination with the other variants described in my
> OP:
>      ... >> C:\...\log\....log 2>&1
> And I observed the same or similar mix of different blocking window types.

Best to hide that inside a script, rather than deal with mixing Windows and 
shell quoting rules!

>> For normal scripts and schedules, I use cron job commands or scripts which log
>> everything under /var/log/.
> 
> In that case, I'd still need `# crond` to run with highest privileges
> as those are the privileges I ultimately need what it would run to
> have.  But maybe I'll try that if I get time to do more testing.

Services drop privileges to $USER privileges unelevated.

> Have you tested the first, most simple, test case from my OP?  It's a
> very elemental test and reproduces the issue reliably for me so it
> would be interesting to hear what you (or anyone else) observes from
> that test case.

It is unlikely it will be different: do they matter?

Most programs probably use regular startup code that opens the stdio handles, 
whereas most shells support non-interactive operation that doesn't.

Doing anything with a console in Scheduled Tasks or any detached background task 
will pop up console windows, perhaps full screen and/or UAC modal if elevated - 
no surprise - don't do that if you don't want to see them!

Use run like XWin startxwin which does not display console windows:

%CYGWIN_ROOT%\bin\run.exe --quote /usr/bin/bash -l -c "cd; exec /usr/bin/startxwin"

Services should be started by cygrunsrv elevated so they get the environment 
they expect to run under.

There are lots of unhelpful interactions between Cygwin and Windows environments 
and programs: you have to pick and choose one and do everything only with those 
programs in that environment. The twain can never (mostly) mix (without effort).

Your tests are play toys: what exactly are you actually trying to do?

How to successfully run Cygwin scheduled tasks without seeing windows:

>> I use scheduled tasks with actions running scripts from /usr/local/bin/ under
>> dash (or bash if required) native path with WD /var/log/ native path e.g.
>>
>> %CYGWIN_ROOT%\bin\dash /usr/local/bin/....sh WD %CYGWIN_ROOT%\var\log
>>
>> with various options (mainly user SYSTEM, logged in or not, highest privileges),
>> and triggers.
>>
>> I never see any windows appearing as the scripts log everything under /var/log/.
>>
>> The scripts run as tasks start and stop Cygwin services, init and run smart
>> reporting, clean up cron job remnants before smart reporting, terminate all
>> processes before running setup.

and note that all stdio is redirected within the script > /var/log/...log 2>&1, 
< /dev/null if necessary, so that the Windows console is never involved.

Have you tried running a non-interactive script from a non-interactive shell as 
suggested?

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

La perfection est atteinte			Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter	not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer	but when there is no more to cut
			-- Antoine de Saint-Exupéry

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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