Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-17-2013, 03:34 PM   #1
LQ Newbie
Registered: Dec 2012
Posts: 15

Rep: Reputation: Disabled
quitting less/more crashes/leaks program

so it seems ( at least on xterm ) that quitting more when I piped in output
from a custom program will leave the terminal hanging at times and I notice that the program leaks memory with valgrind. What is the typical approach to writing programs so that they leave most safely when quitting more/less? Don't ask me for the prog code I don't have it with me, but it's just like a program that reads in a file buffer prints it's contents to stdout and frees the buffer .
I sorta don't get why quitting more/less has to kill the piped process along with it?
is it impossible to implement repiping or dumping to /dev/null?

Last edited by NeoLux; 03-17-2013 at 04:10 PM.
Old 03-18-2013, 12:41 AM   #2
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 129Reputation: 129
you can use "myprogram &" that way it will keep going while giving you the shell back. As for repiping, no, the shell use somewhat static pipe and filter architecture. While one of the program can crash in some circumstances, the command is the sum of the pipes. Kill one and that end the command. As for the free thing, just use apps that doesn't leak.
Old 03-18-2013, 05:52 PM   #3
LQ Newbie
Registered: Dec 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
the problem with myprog & is that I like to see the output of more in the current terminal, but I want to be able to quit with long outputs after I've seen enough and I may not have been clear but the leaked memory is occuring with programs that don't leak e.g. cleanup is performed at the end of main.
I get that quitting more would stop the rest of the original program output but it seems that it also gets terminated before having a chance to clean anything and
I wouldn't have a problem with that except that on some occasions I'm getting a hanging terminal.
Old 03-18-2013, 07:11 PM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,418

Rep: Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398Reputation: 2398
I'm not 100% clear on what your prog invocation looks like, but something like this would work
# set prog to run in back ground (&),
# do not terminate if user logs out (nohup)
# log all output ie stdout+stderr (2>&1)

nohup prog >prog.log 2>&1 &

# now you can watch output &
# quit anytime and prog will continue

tail -f prog.log
I've used this a lot...
Old 03-18-2013, 07:34 PM   #5
LQ Newbie
Registered: Dec 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
ok, thx for the help guys.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] C program for my O/S crashes smeezekitty Programming 5 11-11-2009 08:48 AM
Unknown program memory leaks FAST, 1.5 GB/2 Minutes itz2000 Programming 8 12-17-2008 04:04 AM
Which program crashes on you the most? For me it's 'knotify' Cinematography General 51 06-27-2008 01:46 AM
X crashes on use of GL program DJOtaku Linux - Hardware 2 06-08-2007 10:27 AM
Help! Program Crashes in Mepis pblogic Linux - Newbie 1 02-12-2005 03:25 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration