Hi,
I noticed that if I use any IDOS->Printf() statements in a program, that program will have DSI errors if the printf gets executed if the program is setup to be run as a Tool with an icon indicating start from Workbench instead of start from shell.
Similarly, if a program has a statement such as (IDOS->SystemTags("copy file1 file2",0,0)) and for any reason the copy fails and results in text output, the program locks up if it is run as a tool started with workbench.
Is there a remedy for this? I have tried redirecting the output of the copy command to NIL:, but that does not seem to help.
Thanks
What does IDOS->Output() return? Does it return a valid file handle or ZERO? It should return a valid file handle otherwise this is why Printf() crashes. The SystemTags() launched program by default uses the launching program's standard i/o file handles unless you tell it to do otherwise.
I tried compiling a test program that opens a new CON: window and outputs the three standard i/o filehandles (IDOS->Input(), IDOS->Output() and IDOS->ErrorOutput()) using IDOS->FPrintf(). I tried compiling it with vbcc and gcc (using newlib and clib2) and launching it from WB (start from set to WB on the icon) but wasn't able to reproduce your problem.
@salass00 wrote
"I tried compiling a test program that opens a new CON: window and outputs the three standard i/o filehandles "
I am not opening a con: window at all. I am creating a reaction window with gadgets and listbrowsers.
When I run this program in a shell, it works fine. When I run it from an icon using SHELL as the start method, it runs fine. But if I run it from an icon (as a Tool) and either IDOS->Printf or printf or any AmigaDOS command is called that generates an output (such as in the case where you go to copy a file but it is missing) then I immediately get DSI erros and soon a lockup.
This is the test program I wrote and used:
and compiled using:
gcc -mcrt=newlib -O2 -Wall -o stdio_test stdio_test.c
gcc -mcrt=clib2 -O2 -Wall -o stdio_test stdio_test.c
vc -O2 -o stdio_test stdio_tesr.c
Depending on the startup code used the Output() filehandle (used by Printf()) might be pointing to NIL: when started from WB (like with vbcc all three are the same NIL: filehandle) so if I write anything to it it will just be ignored so in order to get any output I had to create a new CON: filehandle.
@Salass00
You are obviously correct.
The DSI errors I was getting seem to be because of other issues with pointers.
I really appreciate your work,thanks for posting…please write more blogs on such topics.
pest removal cost