This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Starting bash below a non-Cygwin win32 program


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@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]