LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-20-2004, 08:35 PM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Question /var/run/[XXX].pid - Tcl pid code


I wish to implement capturing my pid to be stored in /var/run.

Has anyone done this in Tcl?

Can I please have some sample code?

By using this file, /var/run/[xxx].pid, is this the best way to determine if an istance of your application is already running? Once again, any sample code?

Please advise.
 
Old 05-20-2004, 10:32 PM   #2
liguorir
Member
 
Registered: May 2003
Posts: 256

Original Poster
Rep: Reputation: 30
Question pid code

I think I got it...

#!/usr/bin/wish

if { [ file exists /var/run/app.pid ] == 1 } {
if { [ catch { exec ps h [ exec cat /var/run/app.pid ] } ] == 0 } {
# APP Process is already running, exit
puts "APP process is already running"
exit
} else {
# Remove old pid file, create new pid file
exec rm /var/run/app.pid
exec echo [ pid ] > /var/run/app.pid
}
} else {
# create new pid file
exec echo [ pid ] > /var/run/app.pid
}


Any comments are appreciated.
 
  


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
no pid file in /var/run for programs wolfe2554 Linux - Software 5 01-01-2007 12:02 AM
rm cannot remove /var/run/atd.pid and /var/run/xdm.pid danishmr Linux - Software 1 05-04-2004 08:01 AM
Apache: child pid XXX exit signal Segmentation fault (11) gabriele_101 Linux - Hardware 1 07-23-2003 06:12 PM
can't lock /var/run/crond.pid robeb Linux - General 0 06-08-2002 12:26 PM
cannot write PID to var/run/news cruella Linux - Newbie 1 01-22-2002 06:51 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration