English Amiga Board

Go Back   English Amiga Board > Coders > Coders. General

Thread Tools
Old 26 August 2015, 03:36   #1
Returning fan!

tygre's Avatar
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 542
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:

struct Window *win = get_CON_window()
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...)

tygre is offline  
AdSense AdSense  
Old 26 August 2015, 04:56   #2
Total Chaos forever!

Samurai_Crow's Avatar
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 975
Send a message via Yahoo to Samurai_Crow
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, 12:34   #3
Registered User

Join Date: Jul 2008
Location: Poland
Posts: 494
try Execute("endcli");
arti is offline  
Old 26 August 2015, 14:29   #4
Registered User

Daedalus's Avatar
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,580
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:

Run MyProgram >NIL: <NIL:
Daedalus is offline  
Old 06 September 2015, 06:22   #5
Returning fan!

tygre's Avatar
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 542
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

tygre is offline  
Old 06 September 2015, 07:24   #6
Code Kitten

Join Date: Aug 2015
Location: Montreal/Canadia
Age: 46
Posts: 1,021
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  
AdSense AdSense  

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

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

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 17:32.

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Page generated in 0.14213 seconds with 12 queries