Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Martin Vieregg

Pages: 1 ... 10 11 [12] 13 14 ... 17
166
>Create a pipe in the parent process

OK. That has been done from the beginning of my project.

>Save the parent processes stdin and stdout to temporary file handles

OK. I have them via DosCreateNPipe parameter.

>and call DosDupHandle on stdin and stdout setting them to the write and read handles of the pipe.

I assume that the Outpipe of my program is the stdin of the child program and reverse. So I have to reverse the assignments in DosDupHandle.

>Then call DosExecProgram and following that restore stdin and stdout in the parent.

I read the docu of DosExecPgm and indeed, I found:

Quote
The new process inherits all file handles and pipes of its parent, although not necessarily with the same access rights:

- Files are inherited except for those opened with no inheritance indicated.
- Pipes are inherited.

A child process inherits file handles obtained by its parent process with DosOpen calls that indicated inheritance. The child process also inherits handles to pipes created by the parent process with DosCreatePipe. This means that the parent process has control over the meanings of standard input, output, and error. For example, the parent could write a series of records to a file, open the file as standard input, open a listing file as standard output, and then execute a sort program that takes its input from standard input and writes to standard output.

Because a child process can inherit handles, and a parent process controls the meanings of handles for standard I/O, the parent can duplicate inherited handles as handles for standard I/O. This permits the parent process and the child process to coordinate I/O to a pipe or file. For example, a parent process can create two pipes with DosCreatePipe requests. It can issue DosDupHandle to redefine the read handle of one pipe as standard input (hex 0000), and the write handle of the other pipe as standard output (hex 0001). The child process uses the standard I/O handles, and the parent process uses the remaining read and write pipe handles. Thus, the child process reads what the parent process writes to one pipe, and the parent process reads what the child process writes to the other pipe.

>At that point anything writtten to the pipe's write handle from the parent should go to stdin for the child and anything written to stdout in the child can be read from the pipe's write handle.

I will try it and report here.

167
It still doesn't work even I install an exeption handler for the process. I still get error 205. I run the program asnychrous. The thread rests at DosExecPgm while the program is running and continues when exiting the program.

Could it be possible that only the first cmd.exe which exeuctes the second is in reach for me? I execute cmd.exe first and this cmd.exe executes a second cmd.exe and sends the pipenames as parameters:

program: 'cmd.exe'
parameters: '/C cmd.exe /K <\pipe\mshelloutpipe >\pipe\mshellinpipe 2>\pipe\mshellerrpipe"

If this is a problem, I have to start cmd.exe directly. But how can I hand over the pipe names to the program/process? Via STARTDATA parameter? I haven't found a solution.


168
Quote
The function to send the break signal to a process is DosSendSignalException, using the pid of the process and XCPT_SIGNAL_INTERRUPT  or XCPT_SIGNAL_BREAK as the second argument

Thank you for this useful hint. But it does not work. I get the Session PID from DosStartSession (last parameter). DosSendSignalException is running from another thread (because DosExecPgm blocks the thread). DosSendSignalException returns 205  ERROR_NO_SIGNAL_SENT.

Any ideas?

169
Meanwhile, I could program the basic functionality. It basically works fine already. I needed to program several threads: One for stdin, one for stderr, one for cmd.exe itself. stdout commands (the commands the user enters) are sent via main thread. It was only a few hundred lines of new code, but very tricky and nervy. It works now both with cmd.exe and 4os2.exe. Colors are already working. The problem with the unknown output end of a cmd.exe command is not a real problem. The user always can enter input while cmd.exe output is running but that doesn't matter because noone will do so. The problems above are solved. The next jobs is to implement a selection of editor functionality which I have already programmed for ME Editor which will be quite easy.

But I didn't manage to send a Ctrl-C character/message to cmd.exe to stop execution of a current command output. I tried ASCII #3 and ESC[Cm and ESC#3. Any idea how to send the break command to cmd.exe /4os2.exe? Has anyone studied the 4os2 source code?

Then I wonder if the fine working command to execute cmd.exe via my program
program: 'cmd.exe'
parameters: '/C cmd.exe /K <\pipe\mshelloutpipe >\pipe\mshellinpipe 2>\pipe\mshellerrpipe"

which starts cmd.exe twice is really necessary. Any ideas? Can I use pipenames in the OS/2 STARTDATA structure?

170
kshell has no editor functionality. The main interest is to have full editor functionality, to resize the window and having an endless buffer to restore old outputs.

Meanwhile, the basic functionality works. I want to implement now colors with ESC codes. Where is a documentation about VIO ESC codes?

171
Meanwhile, I have changed the first post: Problem (2) was my failure. The editor has read the input data line by line. This is now fixed.

Problem (3): I remember that in former times, I have programmed text applications where I used a "goto" command. Of course this is not stdout. I fear that this is a general limitation of my program. Perhaps I can add a list of these programs and then a conventional VIO window gets started, or I define a command /VIO where the user can start a VIO window in a command.

Problem (1): Wenn running cmd.exe in a thread (I have got already an input thread in my editor because waiting for input blocks the process),  I still have no access to cmd.exe. But it would be possible to restart cmd.exe for every command the user types into the editor in a specific execution thread. While cmd.exe is running, the thread is frozen, and after finishing cmd.exe, the thread code continues. This could be a clean solution. The current directory is only hold in the editor and every time I execute cmd.exe, I have to hand over the current directory. But this should not be a problem.

172
Programming / problems programming a new text window for cmd.exe/4os2.exe
« on: December 30, 2019, 01:02:08 am »
One year ago, I wrote about my desire to get a substitute for the limited VIO window when using cmd.exe or 4os2.exe without 8000 character limit and with all editor functionality.
https://www.os2world.com/forum/index.php/topic,1859.msg18588.html#msg18588

The last year, I was very busy with other things, but meanwhile I began to program. I am the author of ME Editor and other editors. The editor is an OOP (wdsibyl) project where I can easy manage modifications.

I managed now to excute the original cmd.exe with pipes for stdout, stdin and stderr. The basic input/output functionality works already. But  I need your help with some sophisticated problems.

The editor gets first executed, starts the pipes and executes cmd.exe in the background via
cmd.exe /K >outpipe 2>errorpipe <inpipe

For specific commands like mode, cls the commands will be interpretated by the editor and not cmd.exe, or gets interpretated by both. The current directory will be hold both in the editor and in cmd.exe. I will manage to turn the 4os2 escape codes into colors. All these things seem to make no problems to program (all not programmed yet).

But for three problems I have no solution yet:

(1) While cmd.exe is busy, the editor has to turn into read-only mode. The time period begins with an <ENTER> after typing the command, so the editor knows this moment. But when is the job finished and cmd.exe turns to idle state, the editor should turn to read/write and should accept the next command. I have no idea how the editor can get the information that cmd.exe is in idle state again.

A dirty solution would be to wait for [C:\] or a simular string. But this is not possible. And this is the next problem.

(CHANGED: Problem (2) is non-existant. It was a bug in my editor code.)
(2) A stdout output of cmd.exe waits until the line is finished with an carriagereturn. This has got a strange effect to my program: When starting the program, I do not see [C:\] at the moment. Then I type my command, e.g. "dir", press ENTER and the editor shows the "dir" output. But the last line with the command prompt [C:\] is not shown. It is only shown after entering the next command. Programs with an success indication with dots ...... are invisible while exeuting and waiting. So my question is: Is it possible to force stdout output in cmd.exe when the line is not terminated by a carriagereturn? Or do you have another idea how to sailing round the problem? The only idea for me at the moment is to simulate this output by adding a prompt and to swallow the first line output. Not a pretty solution. And the success dot problem is still not solved.

(3) Not all textmode programs do write into stdout, but there is text output shown nevertheless. This output gets shown in the hidden cmd.exe VIO window and not in my editor window. Can someone explain what this means and perhaps how to get this text in stdout nevertheless?

173
I have got a problem with a print preview function where the size of a font is calculated via the actual window size. Changing the window sizes makes ugly font size steps, because  the FATTRS. lAveCharWidth parameter for GpiCreateLogFont is a integer and not a floating point parameter. The typical values are about 10, so there are 10% steps which really looks ugly.

Other programs manage the problem, e.g. PDF viewers or OpenOffice. Is there a substitute for GpiCreateLogFont or how can I solve this problem?

174
Programming / Re: WinQuerySwitchList Dead Entries
« on: December 02, 2019, 11:55:02 am »
Thank you for the two useful hints. The combination of the two hints solved the problem:
- The owner has been set, but the parent when executing WinCreateWCWindow was set to 0 (it seemed that it was me in 2007 who made the fatal changes.)
- before running WinDestroyWindow, I inserted WinRemoveSwitchEntry
Now it seems to work. I will test it awhile and if it is OK, I send the changes to Wolfgang D.

 

175
Programming / WinQuerySwitchList Dead Entries
« on: November 28, 2019, 04:56:40 pm »
I am using the WDsibyl Delphi-like programming environment where I made already a lot of minor changes the last 15 years...

I have got a problem with dead entries in the window list when closing windows. In most cases, all works fine, but when closing the main window of a program without closing sub windows before, some specific sub windows do not disappear from the window list which is accessable via WinQuerySwitchList API call. In the OS/2 window list (Ctrl-ESC), they disappear. But e.g. in the MOLE list which is using the WinQuerySwitchList API function, they are still shown and since ArcaOS, shutdown faiis with a query "continue?".

If I understand the OS/2 API correct, the WinDestroyWindow (hwnd) API call should delete the Window from the list. The API call is executed twice, one for the form window and one for the frame. So it should disappear from the list, but it does not.

Any ideas?

176
Setup & Installation / Re: RAM disk does not work anymore
« on: August 08, 2019, 11:11:08 am »
Now it works again, I did not understand why. MEMDISK is not part of my Config.sys, this was a failure in the post. Of course I selected the drive letter in the setup program.

177
Setup & Installation / Re: RAM disk does not work anymore
« on: August 07, 2019, 09:26:53 am »
I have realized that the RAM disk is working, but there's a wrong drive letter. os2ldr.cfg holds:
RAMDISK = HPFS PERSIST Z:
RAMDISKNAME = Ramdisk Z

Drive Z seems to be occupied. Any ideas? Drive Y works.

178
Setup & Installation / RAM disk does not work anymore
« on: August 07, 2019, 09:00:43 am »
ArcaOS RAM disk does not work anymore. A hardware problem is possible, I had two other programs which does not run anymore (and I could fix it by re-copying the content of C). Four files are used:

c:\os2ldr.cfg (hidden)
file content:
RAMDISK = HPFS PERSIST *:
RAMDISKNAME = Z

c:\os2\boot\HD4DISK.ADD
c:\os2\boot\MEMDISK.ADD

Then there's a setup program with user interface:
C:\sys\bin\HIDISK.EXE

Any ideas what is also needed ? How can I find out why it fails?

179
Setup & Installation / ArcaOS fix for Windows seamless problem ?
« on: April 07, 2019, 11:02:32 pm »
I am waiting for an ArcaOS fix to solve the Win16 seamless windows problem. Does anyone heared about any efforts? On my old computer, it did work with eCS 1.2 and SNAP. Not only the missing seamless functionality is a problem, the performance of the Win16-only drivers is extremeley bad.

180
Utilities / Re: DO.EXE new version commandline utility 1.99
« on: January 07, 2019, 08:25:22 am »
I've updated the archive files of DO to 2.00a:

http://www.hypermake.com/english/do.html

german language with a short explanation how to use (the readme.txt is only in english)

http://www.hypermake.de/deutsch/do.html

I have decided to write DO in uppercase letters on Unix systems. This seems to work fine.


Pages: 1 ... 10 11 [12] 13 14 ... 17