LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-24-2012, 02:51 PM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Rep: Reputation: 270Reputation: 270Reputation: 270
How can a program run but not be in the process list?


I wrote a program that watches (using inotify) for new images from
remote webcams then makes thumbnails of them. It runs all the time.
Occasionally, so they tell me, it stops making thumbnails. It keeps a
log of every inotification and the program never stops on its own but
the script they use to restart the program looks for the program in
the process list and starts it only if it finds it absent. The only
way this makes sense is if the program continues but its process
either has disappeared from the process list or no longer is
associated with the program. How can this happen?
 
Old 10-24-2012, 06:08 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
Don't know about that, but you could probably replace that script with one that forks a copy of the webcam script then waits on the child-pid, reaping it (and then promptly restarting it) if it dies for any reason. Presumably the parent-process never would die. You can also use inittab to do this sort of thing ... just be sure to start the process as nobody or somesuch. (The "init" process basically does nothing but wait around for its children, being of course the "proud papa" of the whole system ...)
 
Old 10-25-2012, 11:54 PM   #3
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Rep: Reputation: 19
runner

Easy, just take out the code that searches for the process.
 
Old 10-27-2012, 01:04 PM   #4
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Original Poster
Rep: Reputation: 270Reputation: 270Reputation: 270
I didn't report a problem: I asked a question, to wit: can a program continue to execute after it either no longer has a process or the process list no longer associates the process with the program?
 
Old 10-27-2012, 05:58 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
A process is the running instance of a program. It requires a pid to be scheduled.
 
Old 10-30-2012, 12:59 PM   #6
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Original Poster
Rep: Reputation: 270Reputation: 270Reputation: 270
Quote:
Originally Posted by syg00 View Post
A process is the running instance of a program. It requires a pid to be scheduled.
That would mean that the reports people give me mean that a program can continue to run but no longer be identified (presumably in /proc/$PID) with the program that called it?
 
Old 10-31-2012, 12:54 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
No way that I can think of. But anything's possible.
I would be more inclined to doubt the info you are being given, or at least demand incontrovertible proof that all that is alleged is actually what is happening.
Not implying they are lying, possibly just misinterpreting the data.
 
Old 10-31-2012, 11:40 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
A program can fork itself and even replace itself, see the exec... cmds http://linux.die.net/man/3/execl
 
Old 11-01-2012, 03:44 AM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
The OP is the author - hopefully [s]he would be aware of the likelihood of any such practices.
 
Old 11-01-2012, 08:40 PM   #10
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Original Poster
Rep: Reputation: 270Reputation: 270Reputation: 270
Yes, I wrote the program. It makes an entry in a log every time inotify informs it of a new webcam photo. That log shows no sign of the program not working: notifications are logged every 10 or 15 or 30 minutes (different cameras have different frequencies) for months straight and no errors are reported. The people on site tell me that a user informs them occasionally that the thumbnail is not a miniature of the current photo, that not only is it not but that it is black (the webcams run all night) at a time that the sun has been up for hours. There's a lag of a second or so, but not hours. They restart with a script I have written that looks for the program running. That program finds the thumbnail-maker for camera in question not in the process list.

I have rewritten the program to store its PID in /var/run/ and the script to look for that file and report about the PID. So I should find out next time it happens.
 
Old 11-01-2012, 09:27 PM   #11
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,678
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
You might also add another script that runs every minute by cron, picks up that PID from /var/run, shows it from "ps" and also gathers its /proc/PID info. Then if something odd happens, you have some idea of what and when.

Normally a program does not just fall out of the process list. More likely it strangled itself from some bad memory access, and the program name in virtual memory was a victim of this, leading it have some other string for the program name in the "ps" list.

Beyond this thread, you might need to go through debug cycles on the program (which I'm guessing is your intention once you catch it in the misdeed).
 
  


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
[SOLVED] Partial list with ls-l in bash script run in cron but full list run from command line redgshost Linux - General 29 01-16-2011 12:14 PM
How can you force a program/process to run on a specific CPU core? icedfusion Linux - Newbie 2 12-31-2008 10:10 AM
Simple C++ Program: Program Compiles But Won't Run (Segmentation Fault) violagirl23 Programming 3 01-09-2008 12:09 AM
A lot of processes run automatically when I run a single process. dalvirgautam Linux - Enterprise 4 12-01-2006 06:10 PM
process list true_atlantis Linux - Software 2 09-16-2006 08:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:41 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