Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My problem is with FBI (frame buffer image viewer) for Linux, but my question and any answers are perhaps applicable to more than only that program. I don't know. Anyway…

While things are loading on my Raspberry Pi, I display a "Loading screen" through HDMI using FBI. The command in my Bash script is:

/usr/bin/fbi -T 1 -noverbose -a /etc/splash/splashscreen.png

After a couple of days, I notice that I get an "Out of memory" error instead of the splash screens. It turns out every time a splash screen was displayed, a new instance of FBI was loaded. So there were 50 frame buffer image viewers open causing the memory error, I guess.

Is there any way of making sure a new instance of a program isn't opened when I call for it, or will I have to do something like:

pkill fbi
/usr/bin/fbi -T 1 -noverbose -a /etc/splash/splashscreen.png
share|improve this question

migrated from stackoverflow.com Feb 3 '14 at 23:09

This question came from our site for professional and enthusiast programmers.

1 Answer 1

use pgrep to find such processes:

if pgrep fbi; then
    echo "already running"
else
    /usr/bin/fbi -T 1 -noverbose -a /etc/splash/splashscreen.png
fi

or, more quietly

pgrep fbi || /usr/bin/fbi -T 1 -noverbose -a /etc/splash/splashscreen.png

You can use pkill -0 in place of pgrep

share|improve this answer
    
Well, I need to open a new picture in FBI. So using your example won't help. –  Paolo Jan 31 '14 at 12:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.