Running



  • There's something the foobar2000 player does that I'm not quite sure of. When starting, it creates a 0-byte file in its folder called "running". This file is deleted on proper exit, and thus functions as a crash detector.

    It feels iffy. But I know almost nothing about desktop software production, so maybe it's a decent method? Foobar also has a portable mode; maybe that changes things?



  • Sounds dumb, but on the other hand it's also simple and it works... I like it :blush:



  • It's probably used to detect if foobar crashed (if it crashes, it'll offer you to run in safe mode the next time you start it).



  • Yes, that's why I said "it functions as a crash detector".



  • @dhromed said:

    When starting, it creates a 0-byte file in its folder called "running".

    Where is its folder? Is it in one of the Program Files folders?


    Filed Under: Blakeybait


  • :belt_onion:

    I'd say it emulates .lock files on *NIX, used to prevent multiple instances of service from spawning. I always found it a bit.. hacky myself but hey, it's reliable and still used to this day.

    I prefer .pid files myself. If you have to create a file, at least make it useful: .pid files are just text files with main process PID stored in them, so if you ever need it you can just read the .pid file.

    For example:

    $ ps ax | grep apache2 | grep -v grep
    31702 ?        Ss     0:01 /usr/sbin/apache2 -k start
    32131 ?        S      0:00 /usr/sbin/apache2 -k start
    32132 ?        S      0:00 /usr/sbin/apache2 -k start
    32133 ?        S      0:00 /usr/sbin/apache2 -k start
    32134 ?        S      0:00 /usr/sbin/apache2 -k start
    32135 ?        S      0:00 /usr/sbin/apache2 -k start
    32139 ?        S      0:00 /usr/sbin/apache2 -k start
    32140 ?        S      0:00 /usr/sbin/apache2 -k start
    32141 ?        S      0:00 /usr/sbin/apache2 -k start
    32145 ?        S      0:00 /usr/sbin/apache2 -k start
    32500 ?        S      0:00 /usr/sbin/apache2 -k start
    

    Great... which one is the main process in this mess?

    $ cat /run/apache2/apache2.pid 
    31702
    

    Filed under: Oh look, I broke Markdown again


  • Discourse touched me in a no-no place

    @Onyx said:

    Great... which one is the main process in this mess?

    The one running as root and is the parent process of the others perhaps? ;)

    [pjh@lenovo tmp]$ ps auxf | grep httpd | sed -e "s/-D.*$//g"
    pjh      21191  0.0  0.0  22244   976 pts/7    S+   13:32   0:00  |   \_ grep --color httpd
    root     20901  0.1  0.2 323436 18336 ?        Ss   13:30   0:00 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20929  0.0  0.1 323364  9512 ?        S    13:30   0:00  \_ /usr/sbin/fcgi- -f /etc/httpd/conf/httpd.conf 
    apache   20932  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20934  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20935  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20936  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20937  0.0  0.1 323436 10164 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20939  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20941  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    apache   20942  0.0  0.1 323436 10168 ?        S    13:30   0:00  \_ /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf 
    [pjh@lenovo tmp]$ cat /var/run/httpd.pid
    20901
    

    Of course, the tree view is messed up by the limited width of the forum....

    A(n arguably) saner version can be viewed here.



  • @PJH said:

    limited width of the forum.

    Maybe we need a feature request to have overflow:auto on pre blocks?


  • :belt_onion:

    Call me crazy, but for scripting purposes reading the pid file looks simpler somehow.



  • @boomzilla said:

    Maybe we need a feature request to have overflow:auto on pre blocks?

    Only if you want @ben_lubar to post his Dwarf Fortress content in landscape instead of portrait.



  • That would be a plus.



  • Firefox does a similar thing, but it shoves the file in appdata somewhere. I remember there being a bug where it wouldn't delete that file correctly sometimes, and then refused to load at all because it thought it was still running.

    Foobar on the other hand just seems to use it to work out if the program crashed or not. I've had plenty of experience with foobar crashing due to running it off a portable hard drive with a bad cable.



  • @subscript_error said:

    Only if you want @ben_lubar to post his Dwarf Fortress content in landscape instead of portrait.

    I would much like that, actually, because unlike a ginormous vertical graphic, there's no requirement for me to scroll horizontally to get to the next post with my mouse wheel.



  • @boomzilla said:

    I would much like that, actually, because unlike a ginormous vertical graphic, there's no requirement for me to scroll horizontally to get to the next post with my mouse wheel.

    Yeah but what sort of secretimproved horizontal scrollbar would we get? A red trapezoid pinned to the left side of the screen with "3 of 76 arcseconds" and animated emoji arrows?


  • :belt_onion:

    @subscript_error said:

    Yeah but what sort of secretimproved horizontal scrollbar would we get? A red trapezoid pinned to the left side of the screen with "3 of 76 arcseconds" and animated emoji arrows?

    No, it would be vertical, with a left arrow on the bottom, right arrow on the top.

    Arcseconds are, of course, obvious.



  • @Onyx said:

    Arcseconds are, of course, obvious.

    Sounds like my old physics textbooks.
    "The conversion between arcseconds and pixels at this latitude and standard pressure is left as an exercise to the reader."


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.