help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Getting PID


From: Dave Rutherford
Subject: Re: [Help-bash] Getting PID
Date: Fri, 1 Jan 2016 13:11:59 -0500

On Fri, Jan 1, 2016 at 12:22 AM, Danny <address@hidden> wrote:

> So I was thinking ... :
>
[...]

> -get gtkterm's PID and pipe it into /var/lock/LCK..ttyS1
> -send the required data to /dev/ttyS1


You appear not to understand the role of the lockfile. The contents
thereof are not used to determine who has access to the port;
they are merely advisory. The lockfile would work just as well if
it were always empty. It indicates "a process has obtained
exclusive access to this comm port." That exclusive access is
enforced by the kernel, not by something in the filesystem.

So, what you are thinking will not work. You are better off
with the method you're using now, awkward as it is. You
might be able to do something more elegant using ckermit,
though I can't promise anything there.

> What makes you think the last PID is the one you want to use in your
> > script?  How would your script act in this case:
> >
> > address@hidden: pidof application
> > 14 32765 32767
>

Also pay more attention to that observation. If pids wrap around
while you are starting your terminal, is it still the "last one"
which is listed in the lockfile? What would happen running your
program on a system that uses random PID order?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]