Problem with WLS, g.exe, & and pipes

10 views
Skip to first unread message

S.E. Mitchell

unread,
Aug 6, 2022, 9:34:41 AM8/6/22
to TSEPro Support
I have a problem that I would like to ask for help with on
StackOverflow. But I'm having a hard time coming up with a good
title. Advice appreciated!

Title: Under WSL, Windows GUI program thinks stdin is a pipe when said
program is run asynchronously via "&"

Windows Version 10.0.19042.1826

WSL 2, running Ubuntu 20.04.4 LTS

Running a Windows GUI program on WSL:

1) $ g.exe
GetFileType() returns FILE_TYPE_UNKN
Works fine, but the WSL instance is not usable until g.exe terminates.

2) $ ls | g.exe
GetFileType() returns FILE_TYPE_PIPE
Works fine, and data is piped into the application. WSL instance is
not usable until g.exe terminates.

3) $ ls | g.exe &
GetFileType() returns FILE_TYPE_PIPE
Works fine, and data is piped into the application. WSL instance is
immediately available, as the "&" puts g.exe into the background. I
think :)

4) $ g.exe &
GetFileType() returns FILE_TYPE_PIPE
Hangs, because the application thinks stdin is a pipe, and waits
forever for input from it.
How can I somehow detect that nothing is being piped into g.exe?

S.E. Mitchell

unread,
Aug 6, 2022, 10:05:22 AM8/6/22
to TSEPro Support
And, the first scenario should have said "FILE_TYPE_CHAR"

1) $ g.exe
GetFileType() returns FILE_TYPE_CHAR
Works fine, but the WSL instance is not usable until g.exe terminates.

Carlo Hogeveen

unread,
Aug 6, 2022, 11:11:24 AM8/6/22
to sem...@googlegroups.com

Sammy,

I don't have the Windows and C knowledge to give you advice on what you asked for.

As a simple end user I would work around this problem by (probably from a short-named shell script) calling Windows GUI TSE from WSL with
g32.exe -eRestartTSE
where the macro RestartTSE.s is coded as:

#define DOS_ASYNC_CALL_FLAGS _DONT_PROMPT_|_DONT_CLEAR_|_START_HIDDEN_|_RETURN_CODE_|_RUN_DETACHED_|_DONT_WAIT_

proc Main()
Dos(LoadDir(TRUE), DOS_ASYNC_CALL_FLAGS)
AbandonEditor()
end Main

Carlo



Guy Rouillier

unread,
Aug 6, 2022, 8:57:23 PM8/6/22
to TSEPro Support
I'm on Windows 7, so no WSL, but I do have MSYS, which maybe works
similarly enough. In MSYS, your scenarios (1) and (4) work exactly the
same, they both hang. I think this is because when a process is put
into the background, STDIN is no longer available. I found this article
that suggests using PeekNamedPipe to avoid the hang:

https://stackoverflow.com/questions/13816962/win32-readfile-hangs-when-reading-from-pipe

--
Guy Rouillier

On 8/6/2022 9:34:25 AM, "S.E. Mitchell" <sammy.m...@gmail.com>
wrote:
>--
>--- You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
>To view this discussion on the web visit https://groups.google.com/d/msgid/semware/CA%2BgEvkbRWZtKswBuGGPhJfxXtzO7hK_y%2BorMnoyMD2AfG_XpgQ%40mail.gmail.com.


--
This email has been checked for viruses by Avast antivirus software.
www.avast.com
Reply all
Reply to author
Forward
0 new messages