NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 47 48 49 50 51 … 93 Next »
Killing an orphan process when the plugin has died

 
  • 0 Vote(s) - 0 Average
Killing an orphan process when the plugin has died
ubu
Offline

Posting Freak

Posts: 792
Threads: 54
Joined: Jan 2006
#11
2006-12-30, 12:58 AM
zehd Wrote:I have the same trouble with ZProcess which spawns ffmpeg.exe trying to transcode on the fly for viewing files on the MVP...

What I did was:

ZProcess is called by GB-PVR.

It spawns ffmpeg.exe

It also spawns a watcher program (hunter.exe) that checks the PID of GB-PVR and the ffmpeg.exe window to see if they are both up and running.

If I kill GBPVR in Task Manager, Hunter sees it disappear and kills the ffmpeg.exe then exits...

If I kill ZProcess in Task Manager, Hunter sees it disappear and kills the ffmpeg.exe then exits...

If ffmpeg.exe crashes (an error or something) Hunter just exits.

If I exit the transcode process in GB-PVR, (graceful exit) GB-PVR kills ZProcess, and hunter takes care of ffmpeg.exe and itself.

It's not as classy as a real programmer might do, but it's been quite stable.
That's pretty much what I had in mind until Brian suggested using a Windows service. The Windows service approach seems like it will provide an "industrial strength" solution. Hopefully I can make it generic enough that it could be used for ffmpeg, mencoder (or any long running process that needs to be automatically killed if its parent dies) as well as for vlc.

By using "stay alive" calls from the parent to keep the process running, I don't have to worry about who died or why. If nobody sent a "stay alive" message for the past 30 seconds, I kill the process unconditionally (and, optionally, delete the output file created by the process).

Not quite sure what a "real programmer" is. I think it's probably a state of mind. Smile
[SIZE=1]GBPVR v1.3.11 [/SIZE][SIZE=1]HVR-1250, [/SIZE][SIZE=1]ES7300[/SIZE][SIZE=1], 4GB, GeForce 9300, LianLi, Vista.[/SIZE]
[SIZE=1]GBPVR v1.0.08 [/SIZE][SIZE=1]PVR-150, [/SIZE][SIZE=1]P4 2.26GHz, [/SIZE][SIZE=1]1GB,[/SIZE][SIZE=1] GeForce 6200, [/SIZE]Coupden, XP[SIZE=1]
[/SIZE]

Author: UbuStream plugin, UbuRadio plugin, EPGExtra utility.
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,589
Threads: 385
Joined: Dec 2004
#12
2006-12-30, 01:20 AM (This post was last modified: 2006-12-30, 01:26 AM by bgowland.)
ubu Wrote:Thanks, Brian. I waited until I'd tried this before responding to you. Your proposed approach is just what the doctor ordered. Seems like it totally solves my problem.
Cool. Glad to be of help.

Quote:I'd never used a Windows service before but it turned out to be fairly easy to put together.
I wrote my first about 10 years ago for a mailing list distribution service running on NT v3.5. It was in raw C but still not too complicated - just a lot more lines of code. Smile I got hooked on services at that point and use them whenever appropriate. So long as the base service code has all the relevant exception handling etc. they're rock solid.

Quote:I used a simple TCP Channel, as you suggested.
These are sweet - I like the way they're pretty simple to implement and you can pass anything you like through them. I use a message handler interface like this...

Code:
public interface IMessageHandler
{
    bool ProcessCommand(MyRemoteCommand command, object data);
}

MyRemoteCommand is just an enum so I use a 'switch (command)' at the remote end to call whichever method applies. Each method is then able to cast 'data' to whatever object type is appropriate.

Quote:Now I'm worrying about "What if someone kills both GB-PVR and the VLC recording service?" Big Grin
Herein lies madness. Big Grin

Cheers,
Brian
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,589
Threads: 385
Joined: Dec 2004
#13
2006-12-30, 01:44 AM
ubu Wrote:
zehd Wrote:It's not as classy as a real programmer might do, but it's been quite stable.
Not quite sure what a "real programmer" is. I think it's probably a state of mind. Smile
lol - I agree.

I started programming in the late 1970s, when the word 'hacker' just meant someone that had to make it up as they went along because there wasn't much in the way of documentation around.

These days I still hack stuff together if I need a quick fix for a problem. Sometimes I get time to do something elegant. Mostly it's something in between. If it works, it works. Smile

Cheers,
Brian
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#14
2006-12-30, 06:27 AM
bgowland Wrote:lol - I agree.

I started programming in the late 1970s, when the word 'hacker' just meant someone that had to make it up as they went along because there wasn't much in the way of documentation around.

These days I still hack stuff together if I need a quick fix for a problem. Sometimes I get time to do something elegant. Mostly it's something in between. If it works, it works. Smile

Cheers,
Brian

here, here
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#15
2006-12-30, 06:29 AM
ubu Wrote:That's pretty much what I had in mind until Brian suggested using a Windows service. The Windows service approach seems like it will provide an "industrial strength" solution. Hopefully I can make it generic enough that it could be used for ffmpeg, mencoder (or any long running process that needs to be automatically killed if its parent dies) as well as for vlc.

By using "stay alive" calls from the parent to keep the process running, I don't have to worry about who died or why. If nobody sent a "stay alive" message for the past 30 seconds, I kill the process unconditionally (and, optionally, delete the output file created by the process).

Not quite sure what a "real programmer" is. I think it's probably a state of mind. Smile

Yeah I was thinking my 'hunter.exe' would be nice to share, but I like the service idea. I built my first service a long while back in VB4, and it was a kludge (but it worked). When I came out of 'retirement' to write ZProcess I thought I'd be better off staying away from services for now...
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): « Previous 1 2


Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP plugin for Kodi sgilani 2 3,018 2022-10-17, 12:44 AM
Last Post: sgilani
  New Systems Plugin kirschey 10 3,506 2020-11-14, 08:01 PM
Last Post: sub
  VIdeo playback from plugin mvallevand 5 3,598 2015-08-06, 10:43 PM
Last Post: sub
  Attention Sub: Open TV / Custom Data Grabber plugin Benoire 2 2,982 2014-11-14, 02:05 AM
Last Post: Benoire
  API docs to help with plugin development? McBainUK 3 2,841 2013-06-08, 06:14 PM
Last Post: sub
  Refreshing TV Guide Data (after System plugin EPG update) imilne 13 6,284 2013-03-24, 08:03 PM
Last Post: imilne
  sabnzbd plugin to show processed files Wakalaka 1 2,007 2013-03-12, 06:48 AM
Last Post: psycik
  Plugin problems with started from the command line mvallevand 11 5,161 2012-08-12, 07:56 PM
Last Post: sub
  Get NextPVR data directory from outside a plugin McBainUK 3 2,316 2012-02-11, 05:42 PM
Last Post: mvallevand
  Weather Plugin imilne 0 1,489 2012-01-15, 08:33 PM
Last Post: imilne

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode