English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 26 August 2015, 02:36   #1
tygre
Returning fan!
 
tygre's Avatar
 
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
Closing current Shell window programmatically?

Hi all!

I wonder if someone would know and could point me to a piece of C code that it a CLI program that closes the Shell window in which it runs programmatically?

I tried something like:

Code:
struct Window *win = get_CON_window()
CloseWindow(win);
but this piece of code "freezes" all my next Shell windows and generate an unseeable Enforcer hit: any new Shell window is just empty and unresponsive (Most likely because I am not closing all the resources...)

Thanks!
tygre is offline  
Old 26 August 2015, 03:56   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
Have you tried printing an EOF to the console? On the keyboard it is represented by control-backslash.
Samurai_Crow is offline  
Old 26 August 2015, 11:34   #3
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 662
try Execute("endcli");
arti is offline  
Old 26 August 2015, 13:29   #4
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
You need to detach your program from the shell that spawned it before it can close, otherwise the task expects the shell to be there for certain resources (i/o streams, OS messages and signals, current directory etc.), and pulling it out from beneath your program causes bad things to happen as you've found. I don't have any example code I'm afraid, but from memory, you need to spawn a new process with CreateProcess() or something similar (this will be your actual program), and then end your current task (which basically acts as a small launcher), thus freeing up the shell to be closed.

A much simpler option is to just use a little script to launch your program, something like:

Code:
Run MyProgram >NIL: <NIL:
EndCLI
Daedalus is offline  
Old 06 September 2015, 05:22   #5
tygre
Returning fan!
 
tygre's Avatar
 
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
Hi all!

Thanks for your suggestions: system("EndCLI"); closes the Shell window while printf("%c", 0x04); does not do anything, maybe I am not using the correct control character?

Anyhow, I realised that closing the Shell could be very annoying so, at the end, I don't think that I should use it

Thanks!
tygre is offline  
Old 06 September 2015, 06:24   #6
ReadOnlyCat
Code Kitten
 
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
Closing the CLI should be the responsibility of the user or program which opened it, there is nothing more annoying than a command line program which kills your CLI or script when there are many more commands left to execute afterward.
ReadOnlyCat is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear background color for Shell window- Shell-StartUp fc.studio support.Apps 13 25 March 2022 18:52
UnArchiving LHA Files Programmatically: Confused about XPK, XAD, XFD tygre Coders. C/C++ 18 17 June 2015 00:26
Snapshot Amiga Shell window? TenLeftFingers support.Apps 3 15 June 2015 16:38
FS-UAE Launcher window resizing & closing Emu support.FS-UAE 2 14 April 2015 10:24
Closing a window with shared Messageport? AGS Coders. System 0 18 March 2015 15:05

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:10.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.24357 seconds with 13 queries