Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 31 Aug 2014, 06:41
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GTKdialog leftovers
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Tue 27 Oct 2009, 15:02    Post_subject:  GTKdialog leftovers
Sub_title: Files left in /tmp by a GTKdialog script
 

When a program is made with GTKdialog , it seems to be common practice to leave any files created in /tmp to be removed upon reboot.
But would it not be cleaner to add one line to the end of the script to remove the file in /tmp before exiting?
I will use as an example a program written to use a /tmp file called number.
The script is run. The /tmp/number file is created and used.
Upon exiting the script, the /tmp/number file is still there.
With the addition of one line, "rm /tmp/number" before the script is ended, the /tmp/number file is removed without rebooting.

End of script example:

gtkdialog3 -p MAIN_DIALOG
rm /tmp/number
unset -f add
unset MAIN_DIALOG


Comments?
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2237

PostPosted: Tue 27 Oct 2009, 15:07    Post_subject:  

Hey, that's a novel idea! Clean, orderly coding! And suggested by a beginner, to boot. I hope you'll do your own work following those principals and keep on hammering away at those who don't -I run out of breath sometimes...
Back to top
View user's profile Send_private_message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Tue 27 Oct 2009, 15:15    Post_subject:  

I wondered if the command to remove the file from /tmp would leave a whiteout file in it's place.
I just checked and it does not.
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Tue 27 Oct 2009, 15:58    Post_subject:  

Hi 8-bit; I believe that /tmp is in ram and is not part of the union ( but I may be wrong...).
So that`s why it comes up clean after every boot, the Save file doesn`t over shadow it.
That`s why all temporary dirs., files, links, pipes, and even mount points are best put into /tmp
When I write an app. I usually make a /tmp sub dir. for it so it doesn`t make a mess out of /tmp
Like: /tmp/SambaBrowser
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Tue 27 Oct 2009, 16:07    Post_subject:  

The only way it would leave a whiteout file in its place is if the file copies over one that exists in a unioned sfs.

Even better would be to create folder in tmp and remove the folder.

Code:
rm -rf /tmp/myprogramtmpfolder


rather than a line of code for each file

also some programs leave the files there intentionally for debugging or other reasons

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Tue 27 Oct 2009, 19:10    Post_subject:  

I guess what I am getting at here is that if /tmp is located in memory and one has a limited amount of memory, the /tmp files created take up memory that could be recovered by deleting them when the program ends.
If you want an extreme example, open a terminal and type free.
Now copy an big file to /tmp.
In the terminal, type free again.
Notice the decrease in free ram?
But I also noticed that deleting the big file from /tmp does not fully recover the free ram.
Puzzled....
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0492s ][ Queries: 12 (0.0055s) ][ GZIP on ]