delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com> |
List-Archive: | <http://sourceware.cygnus.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT sourceware DOT cygnus DOT com> |
List-Help: | <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs> |
Sender: | cygwin-owner AT sourceware DOT cygnus DOT com |
Delivered-To: | mailing list cygwin AT sourceware DOT cygnus DOT com |
From: | "Mike Stevens" <stevens AT connectfree DOT co DOT uk> |
To: | <cygwin AT sourceware DOT cygnus DOT com> |
Subject: | Starting bash below a non-Cygwin win32 program |
Date: | Thu, 9 Sep 1999 21:40:19 +0100 |
Message-ID: | <000101befb03$880d4fc0$968901d4@stevens> |
MIME-Version: | 1.0 |
X-Priority: | 3 (Normal) |
X-MSMail-Priority: | Normal |
X-Mailer: | Microsoft Outlook 8.5, Build 4.71.2173.0 |
Importance: | Normal |
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3155.0 |
I am using a 3rd party telnet demon to log onto an NT server. A 3rd party win32 application running below the telnet demon then starts a program called 'launch' which then starts an interactive Bash shell. (I have to use the -i switch to make bash interactive since it realises that stdin is not a console.) The purpose of the 'launch' program is to do NL to CR/LF conversion on all output from bash. The stty settings don't work because stdin is not a console. I know that the telnet processes should handle the NL to CR/NL conversion but in this case it is not possible. I have 3 versions of the launch program. All 3 have problems. An even better solution however would be to somehow get Cygwin to treat stdin as a console and allow an stty setting to do the conversion. I doubt if this is possible though... Any comment please.. 'Launch' version 1 ------------------ This was just an experimental version that doesn't do the character conversion. It just used execl() to start the bash process. The launcher process didn't disappear as would be expected on Unix but stayed until the bash exited. It then died as expected. This is due to the way Cygwin implements exec(). Bash worked fine but without the NL to CR/LF conversion. Both the launcher and bash exited as soon as I typed exit\n. 'Launch' version 2 ------------------ This is written in Microsoft C. It creates threads to copy the input, output and error channels through pipes to the child bash process. The thread that reads the output from bash will get an error when bash dies. This thread then closes all the channels that are being used by the other threads to cause them to get errors. It then exits. The program works fine until you type exit\n to the bash process. I would expect the bash process to exit immediately but is doesn't. It doesn't exit until something else is typed. This is a major problem when executing non-interactive shell scripts using bash -c. Why should bash hang when it should exit? What is it waiting for? 'Launch' version 3 ------------------ This is written in Cygwin. It uses dup() to save the final stdout. It uses dup2() to make the current stdout be to an anonymous pipe. It then uses vfork() and execl() to start the bash process. When it tries to read from the other end of the pipe, it returns immediately with an error. The program was tested on Unix and it worked fine. Is this doing something that conflicts with Cygwin's handling of exec()? Current environment ------------------- I am using B20 with the 19990115 version of CYGWIN1.DLL on NT4 sp3 The environment variable CYGWIN32 is set to binmode. All mounts are binary. I would be very grateful for any help. I am running out of ideas. Mike -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |