LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2017, 03:41 PM   #1
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,578

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Runaway train


I might be testing an unfinished program. A bug causes the program to write six bazillion lines to an output file. Is there a way to prevent this? A way for Linux Mint to detect a runaway train?

This has not happened (honest!) but the possibility is worrisome.

Daniel B. Martin
 
Old 09-23-2017, 04:39 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,199

Rep: Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391
Code:
~$ help ulimit
ulimit: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
[...]
      -f	the maximum size of files written by the shell and its children
~$ ulimit -f 10
~$ ulimit -a
[...]
file size               (blocks, -f) 10
~$ yes > foo.txt
File size limit exceeded
~$ ls -sh foo.txt 
12K foo.txt
This doesn't seem to defend against writing six bazillion files of 1 line each though (there is ulimit -n for max number of open files, but that's not a barrier if the program closes each file quickly).

It might also be worth limiting virtual memory (ulimit -v) to somewhere around the size of your physical RAM to prevent a single program with a major memory leak from filling up your swap space (this tends to slow down the entire system as it writes to swap).
 
1 members found this post helpful.
Old 09-25-2017, 03:17 PM   #3
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 173

Rep: Reputation: 59
Quote:
t might also be worth limiting virtual memory (ulimit -v) to somewhere around the size of your physical RAM to prevent a single program with a major memory leak from filling up your swap space (this tends to slow down the entire system as it writes to swap).
First of all the OP isn't discussing memory leaks but rather a program which goes into endless loops generating unlimited amounts of data.

There is a much better way of handling runaway programs and files. You need to create a separate partition for the output of such un-trusted programs. A partition of modest size such as 100 - 500 MB would fill up fast and then generate an error code if writes were attempted to a full file system. You would need to check the error code after each write operation to this small partition. Filling up a small separate partition wouldn't affect your main file system.

This separate partition technique is traditionally used by developers to keep an un-trusted program from filling up your main file system.
 
1 members found this post helpful.
Old 09-25-2017, 03:43 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,199

Rep: Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391Reputation: 1391
quota and setquota may also be of interest.
 
2 members found this post helpful.
  


Reply


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
Runaway smbd wpost Linux - Server 1 12-16-2011 06:31 AM
runaway file? misophist Linux - Software 6 03-09-2009 12:52 PM
runaway terminal Radovitch Ubuntu 1 05-07-2007 02:17 PM
RedHat 8 runaway mherring Linux - Software 3 01-20-2003 03:25 PM
runaway mouse... jhorvath Linux - Software 1 10-03-2002 07:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:42 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration