LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-17-2013, 02:34 PM   #1
NeoLux
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 03:10 PM.
 
Old 03-17-2013, 11:41 PM   #2
Elv13
Member
 
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, 04:52 PM   #3
NeoLux
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, 06:11 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I'm not 100% clear on what your prog invocation looks like, but something like this would work
Code:
# 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, 06:34 PM   #5
NeoLux
LQ Newbie
 
Registered: Dec 2012
Posts: 15

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


Reply



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 07:48 AM
Unknown program memory leaks FAST, 1.5 GB/2 Minutes itz2000 Programming 8 12-17-2008 03:04 AM
Which program crashes on you the most? For me it's 'knotify' Cinematography General 51 06-27-2008 12:46 AM
X crashes on use of GL program DJOtaku Linux - Hardware 2 06-08-2007 09:27 AM
Help! Program Crashes in Mepis pblogic Linux - Newbie 1 02-12-2005 02:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:22 PM.

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