Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-05 Thread Edward Bartolo
First of all, thanks for taking the time to write to me. Using "ps xao pid,ppid,comm", I found what I described to you: precisely, that orphaned processes were adopted by the GUI frontend. The frontend's pid was listed as the zombies' ppid. Now, this issue has little effect on the code as I am

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-05 Thread Edward Bartolo
Quote: <> So what is the difference between an "orphaned process", i.e. a process whose parent has exited after giving birth to a child process and one which replaces the original process effectively giving its parent a death sentence? Sorry, but it looks there is only a very subtle difference

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-05 Thread ibid . ag
On Sat, Sep 05, 2015 at 08:52:39PM +0100, Edward Bartolo wrote: > Quote: < process (that's done via fork and not via execve) and it's not adopted > by the grand parent but by init.>> > > So what is the difference between an "orphaned process", i.e. a > process whose parent has exited after giving

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-05 Thread Nate Bargmann
Edward, A rather thorough reference is "The Linux Programming Interface" available from: http://www.man7.org/tlpi/ and other retailers. HTH, - Nate -- "The optimist proclaims that we live in the best of all possible worlds. The pessimist fears this is true." Ham radio, Linux, bikes, and

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-04 Thread Edward Bartolo
I am not putting in doubt what you are telling me. In my implementation, the backend is run from within the code of the frontend, so its ppid is the pid of the frontend. Occurrences of execl, create another child process which is owned by the backend, but the latter, dies as soon as the child

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread KatolaZ
On Thu, Sep 03, 2015 at 06:53:46PM +0100, KatolaZ wrote: [cut] > > OK, I admit it might had been a tad too cryptic, but my intentions > were good. What I mean is that the parent has to set a handler for > SIGCHLD, and the handler has to call wait() [or waitpid(-1, )] > to reap the dead child.

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread Steve Litt
On Thu, 3 Sep 2015 18:24:51 +0100 Edward Bartolo wrote: > I found that the created zombies are owned by root and the frontend > does not run with root privileges. I think, this may be the reason. > > The reason why zombies are created is that we are effectively > replacing

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread Laurent Bercot
On 03/09/2015 18:35, Steve Litt wrote: I'd figure out how to stop those zombies from happening in the first place. It's pretty hard to create a zombie: I think you have to doublefork and then terminate. Nope, a zombie is actually very easy to create: - have a process parent that spawns a

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread KatolaZ
On Thu, Sep 03, 2015 at 06:36:39PM +0100, KatolaZ wrote: [cut] > > Sorry guys, I didn't get through the whole thread, but I wanted to say > just one obvious thing: if your program works correctly, then it is > *very* difficult (if not impossible) to create and leave zombies > around. If the

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread Edward Bartolo
I kept a multithreaded netman version installed on my computer so that I would be able to connect to wifi with a couple of button clicks. All I can say is, that it doesn't create zombies and it is well behaved. What we should do is do away with execl which *replaces* backend effectively killing it

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread tilt!
Hi Edward, AFAIK Status must be a pointer, because fpwaitpid will write information into that status. Also, you should check the return value of fpwaitpid(): 0 : nothing has happened -1: an error occurred, check fgGetErrno other: the pid of a child where something happened so like

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread Edward Bartolo
I am trying to reap zombies. The "while(fpwaitpid" pascal code is freezing my application. * procedure handle_sigchld(sig: longint; info: psiginfo; context: psigcontext); cdecl; var Status: cint; a_pid: pid_t;

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-03 Thread Rainer Weikusat
Edward Bartolo writes: > I am trying to reap zombies. The "while(fpwaitpid" pascal code is > freezing my application. > > * > procedure handle_sigchld(sig: longint; info: psiginfo; context: >

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-02 Thread tilt!
On 09/02/2015 10:27 PM, Steve Litt wrote: > Personally, I'd go way out of my way never to multithread unless > there were a huge reason to do so. Your app does such a small, quick > job that there's no reason. > > You mentioned the front and back end communicating with each other, > and

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-02 Thread Steve Litt
Personally, I'd go way out of my way never to multithread unless there were a huge reason to do so. Your app does such a small, quick job that there's no reason. You mentioned the front and back end communicating with each other, and everyone mentioned fifos. I agree. And if there's a reason

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-02 Thread Edward Bartolo
What about multithreading? Should I do away with it and let the frontend monitor for zombies to call waitpid? Edward On 02/09/2015, Steve Litt wrote: > On Wed, 2 Sep 2015 11:47:34 +0100 > Edward Bartolo wrote: > >> Hi all, >> >> I think, I found an

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-02 Thread Edward Bartolo
Hi, Thanks for the reply. If Unix Domain Sockets can do the job nicely, why not? However, I will wait for other replies for their opinion. Thanks. On 02/09/2015, dr.kl...@gmx.at wrote: > Am Mittwoch, 2. September 2015 schrieb Edward Bartolo: >> Hi all, >> >> I think, I found

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-02 Thread Edward Bartolo
Quote: "This means the GUI/ frontend either needs to handle SIGCHLD in order to get notified when a child process terminates so that a suitable wait call (which doubtlessly exists in the Free Pascal libraries) can be used to get rid of the zombie without having to wait for it or (the by far most

Re: [DNG] Doing away with multi-threading in my project (netman)

2015-09-02 Thread Rainer Weikusat
Edward Bartolo writes: [...] > The idea is this: the backend would be converted into some sort of a > daemon exporting one function and importing another one. The frontend > would use the exported function from the backend to send it commands. > The backend would do the same