LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 01-09-2015, 01:11 PM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Detect process with constantly changing ID


Have a process called 'software' that sometimes has an issue with an image, here called 'image.png'

When this happens, 'software' will die, and restart, over and over and over, constantly changing PIDs - but keeping the same image name 'image.png'

What would be your suggestiion for monitoring for this case?
 
Old 01-09-2015, 01:21 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
find the binary executable file and chmod it to non-executable.
 
Old 01-09-2015, 01:24 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
1) That isn't monitoring / testing for a condition
2) That will keep it from working at all
 
Old 01-09-2015, 01:33 PM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,840

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I do not know what is your goal, what do you want to monitor and why. But I would look for its parent process first.
 
1 members found this post helpful.
Old 01-09-2015, 01:37 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
I explained it up there in the first post. An example would be this:
Code:
1989 ?        Ss     0:00 /usr/sbin/software /tmp/image.png
See that process and filename? A second later:

Code:
1992 ?        Ss     0:00 /usr/sbin/software /tmp/image.png
See that? The pid changed, but 'software' is trying to work on image.png again?

Keeping in mind that image.png might be anything(image01.png or thisimage.png perhaps) - What is your suggested way of detecting this failure?
 
Old 01-09-2015, 01:48 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Does it generate any messages to a logfile when it "fails" and restarts?

You do not say what process invokes software originally, whether it works through some directory of images, is it cron driven or attended, etc.

Suggestions might be to tail messages and look for repetitions, or modify the software to create a lockfile based on or including the image filename which would block or abort, or maybe write a wrapper script to detect and abort.

If PID (process info) is the ONLY way of identifying it, then write a script to ps | grep | compare last ? fail : continue | save last

Last edited by astrogeek; 01-09-2015 at 02:04 PM.
 
1 members found this post helpful.
Old 01-09-2015, 02:23 PM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
First of all, you should find out who (which user) runs this program, what does it do (or is it supposed to do), is this behaviour considered to be ok?
 
1 members found this post helpful.
Old 01-09-2015, 02:49 PM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Will do. Thanks for the hints.
 
Old 01-09-2015, 05:23 PM   #9
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
Parent and child share buffers and file descriptors. Maybe /tmp/image.jpg belongs to parent process forking in reincarnation of "software". I would try lsof for /tmp/image.pgn.
 
1 members found this post helpful.
Old 01-12-2015, 01:48 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,840

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
sometimes you can remove that image.png and the "software" will drop an error message - and that will help you to identify it.
 
1 members found this post helpful.
Old 01-12-2015, 02:30 AM   #11
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Wait, is the actual name of the binary program "software"? If so, simply remove the program-file, remove the user that owns it, and remove every other files of that user. It must be some idiot having fun with your computer.
 
1 members found this post helpful.
Old 01-12-2015, 07:12 AM   #12
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
How are you running this? Did you write "software".

Actually, forget that, you can write a program to run "software" from within a C program and check for signals. See this blog about a daemon and how to have it monitor the children. Start down at the chunk about creating child processes and monitoring them. Check exit status, and so forth.

And if something dies, it shouldn't be recreating itself, there's a controller, daemon, or service which is already monitoring it and restarting it.
 
1 members found this post helpful.
  


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] CPU constantly 50% also pcmanfm constantly respawning. linuxpicaxe Linux - Software 2 09-11-2012 04:45 PM
[SOLVED] Pid of process changes constantly konzo Linux - Newbie 5 08-08-2010 03:48 PM
Apple Keyboard constantly changing keycodes in X Vinter Linux - Hardware 1 02-17-2010 08:32 AM
How to detect new process creation? hkhalid Programming 5 09-13-2009 05:31 PM
Constantly changing text color on the console jpanski Linux - Newbie 2 01-09-2008 02:35 PM

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

All times are GMT -5. The time now is 06:49 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
Open Source Consulting | Domain Registration