Terminal closes too quickly

Linux specific questions.
Post Reply
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Terminal closes too quickly

Post by sancho3 »

The terminal window fills with text that can only be some kind of error but it happens after the last sleep command in my program.
It shuts immediatly and I can't figure out what it is saying. I can't retrieve that window.
I have tried compiling from the terminal but it doesn't fill the terminal with text in that case.
How do I stop that terminal window from closing after my run?
Ubuntu
Last edited by sancho3 on Mar 28, 2018 4:55, edited 1 time in total.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Terminal closes too quickly

Post by caseih »

What operating system? Since you use the word Terminal I'm assuming Linux. In order to keep the terminal window open you need to run your application from the terminal prompt.
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: Terminal closes too quickly

Post by sancho3 »

Thanks.
I found the error in my program.
It seems rather pointless to fill a terminal window with debug info and then shut it down.
Running from terminal gives one line error, Segmentation violation. Its some help, but not much.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Terminal closes too quickly

Post by D.J.Peters »

sancho3 wrote:Running from terminal gives one line error, Segmentation violation. Its some help, but not much.
If you need more info try this:
fbc -exx yourcode.bas
./yourcode

or use the debugger:

fbc -g yourcode.bas
gdb ./yourcode
[r] <-- means press r for run

Joshy
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: Terminal closes too quickly

Post by Dinosaur »

Hi All
If you need more info try this:
fbc -exx yourcode.bas
./yourcode
Another note for my Linux tricks notebook.

I had only ever used -exx to check for array bounds.
Whenever I tried to run the program compiled with -exx with Win or Dos it would hang or not run.
Mind you this was years ago.

Actually found an error that has gone unnoticed when I just tested this.
Thank you Joshy

Regards
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Terminal closes too quickly

Post by caseih »

Definitely essential tips from Joshy. During the development phase, -exx should always be used, as should -g. And you should always run your app from the terminal also. Don't rely on double-clicking an icon as you'll miss vital information. I'm a bit surprised you even saw a terminal window pop up. On my desktop, double-clicking an executable runs it without any standard I/O streams at all, which means a non-graphical FB program would probably do appear to do nothing at all. On your distro it must be defaulting to running executables in a terminal window, which is reasonable for normal terminal apps I suppose.

One thing I like about Linux over Windows is that all applications can use standard out and standard error, but it's always hidden unless you run it from a terminal directly. This is great as normal users would never see or be bothered by information, but if someone wants it, it's there when they run it from a terminal. Unlike Windows where if you use standard out or standard error at all, it pops up an annoying console window. This means you have to make your program completely silent for production applications.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Terminal closes too quickly

Post by jj2007 »

caseih wrote:One thing I like about Linux over Windows is that all applications can use standard out and standard error, but it's always hidden unless you run it from a terminal directly. This is great as normal users would never see or be bothered by information, but if someone wants it, it's there when they run it from a terminal. Unlike Windows where if you use standard out or standard error at all, it pops up an annoying console window. This means you have to make your program completely silent for production applications.
On Windows, you can build it as a gui app and then use AllocConsole if a switch is present.
Alternatively, you can build as a console app and use FreeConsole to get rid of the console.
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Terminal closes too quickly

Post by badidea »

With Geany you can do this (Linux or Windows):
Image
Now, in this case:
F8 = Compile with extra checks
F9 = 'Normal' compile (faster)
F5 = Run
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: Terminal closes too quickly

Post by Kuan Hsu »

Using -exx for array bounds check and: viewtopic.php?t=25835#p234749
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: Terminal closes too quickly

Post by sancho3 »

Good tip about GDL, I forgot I could use that from the terminal or even in the IDE.
I did use -exx. I absolutely use that all the time. I am running from within the IDE (poseiden on Ubuntu) normally, and FB produces a terminal window and a graphic window if you use screenres.
In this case the terminal window was filling with debug info and running from the command line would only give the limited error message.
At the end of the day the problem was in a destructor and if I had been diligent I would have found it much sooner.
Post Reply