Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Overflow on /dev/null, please empty the bit bucket.


devel / comp.unix.programmer / temporarily holding a lock in bash

SubjectAuthor
* temporarily holding a lock in bashRainer Weikusat
`* Re: temporarily holding a lock in bashBranimir Maksimovic
 `* Re: temporarily holding a lock in bashRainer Weikusat
  `* Re: temporarily holding a lock in bashBranimir Maksimovic
   `* Re: temporarily holding a lock in bashRainer Weikusat
    `* Re: temporarily holding a lock in bashBranimir Maksimovic
     `* Re: temporarily holding a lock in bashRainer Weikusat
      `- Re: temporarily holding a lock in bashJim Jackson

1
temporarily holding a lock in bash

<87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16710&group=comp.unix.programmer#16710

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: temporarily holding a lock in bash
Date: Sun, 10 Oct 2021 21:27:13 +0100
Lines: 26
Message-ID: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net F7I9FGvs87urZMV2P/uDBAzSUJ16jfPn/Wfx5IggG6qwwVUsA=
Cancel-Lock: sha1:g9jMPOfX6PXV5A6NTcjaix5/8fA= sha1:lZ2MCXYrLMVfo26SofwHksmKQLI=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Sun, 10 Oct 2021 20:27 UTC

coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
read x <&${COPROC[0]}
----

The corpoc command executes a shell command in a forked shell without
waiting for it. Stdin and stdout of the coprocess are connected to pipes
whose file descriptors are available as member 0 and 1 of an array, by
default named COPROC.

The command used here acquires an exclusive lock on the file passed as
argument to -w and then execs another command (which inherits the
lock). In this case, this other command writes a \n terminated string to
its stdout and then reads from its stdin until an EOF is encountered
which causes it to terminate, implicitly releasing the lock.

The parent shell will remained blocked in the read until it has read the
line written by the lock-keeper command. This means execution of the
main script will be paused until the lock could be acquired. The two
lines above are part of a shell function defined as ()-delimited
block. The function will thus run in a forked subshell. Upon return of
the function, the subhshell will exit which causes the stdin descriptor
of the locking coprocess to be closed, ultimatively leading to release
of the lock.

Comments, opinions or alternate suggestions, especially something which
would work with a stock /bin/sh very much appreciated.

Re: temporarily holding a lock in bash

<xrL8J.69841$2B4.52331@fx04.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16711&group=comp.unix.programmer#16711

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx04.iad.POSTED!not-for-mail
Newsgroups: comp.unix.programmer
From: branimir.maksimovic@icloud.com (Branimir Maksimovic)
Subject: Re: temporarily holding a lock in bash
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 35
Message-ID: <xrL8J.69841$2B4.52331@fx04.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Mon, 11 Oct 2021 00:20:45 UTC
Organization: usenet-news.net
Date: Mon, 11 Oct 2021 00:20:45 GMT
X-Received-Bytes: 2105
X-Original-Bytes: 2054
 by: Branimir Maksimovic - Mon, 11 Oct 2021 00:20 UTC

On 2021-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
> coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
> read x <&${COPROC[0]}
> ----
>
> The corpoc command executes a shell command in a forked shell without
> waiting for it. Stdin and stdout of the coprocess are connected to pipes
> whose file descriptors are available as member 0 and 1 of an array, by
> default named COPROC.
>
> The command used here acquires an exclusive lock on the file passed as
> argument to -w and then execs another command (which inherits the
> lock). In this case, this other command writes a \n terminated string to
> its stdout and then reads from its stdin until an EOF is encountered
> which causes it to terminate, implicitly releasing the lock.
>
> The parent shell will remained blocked in the read until it has read the
> line written by the lock-keeper command. This means execution of the
> main script will be paused until the lock could be acquired. The two
> lines above are part of a shell function defined as ()-delimited
> block. The function will thus run in a forked subshell. Upon return of
> the function, the subhshell will exit which causes the stdin descriptor
> of the locking coprocess to be closed, ultimatively leading to release
> of the lock.
>
> Comments, opinions or alternate suggestions, especially something which
> would work with a stock /bin/sh very much appreciated.

u don;t wanna wait but you use *lock* :P

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Re: temporarily holding a lock in bash

<87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16712&group=comp.unix.programmer#16712

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!news.neodome.net!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: temporarily holding a lock in bash
Date: Mon, 11 Oct 2021 15:39:59 +0100
Lines: 35
Message-ID: <87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
<xrL8J.69841$2B4.52331@fx04.iad>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net xVfUzQwvJmw0z29eCiAXCgavB8GktzNGP5vezawbF6C4H2Ms8=
Cancel-Lock: sha1:wn1sP9WRSouEcQjuozCpY5dyBik= sha1:LrsS8cMFOJd7I2pUPw/xyDEfzDY=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Mon, 11 Oct 2021 14:39 UTC

Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
> On 2021-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>> coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
>> read x <&${COPROC[0]}
>> ----
>>
>> The corpoc command executes a shell command in a forked shell without
>> waiting for it. Stdin and stdout of the coprocess are connected to pipes
>> whose file descriptors are available as member 0 and 1 of an array, by
>> default named COPROC.
>>
>> The command used here acquires an exclusive lock on the file passed as
>> argument to -w and then execs another command (which inherits the
>> lock). In this case, this other command writes a \n terminated string to
>> its stdout and then reads from its stdin until an EOF is encountered
>> which causes it to terminate, implicitly releasing the lock.
>>
>> The parent shell will remained blocked in the read until it has read the
>> line written by the lock-keeper command. This means execution of the
>> main script will be paused until the lock could be acquired. The two
>> lines above are part of a shell function defined as ()-delimited
>> block. The function will thus run in a forked subshell. Upon return of
>> the function, the subhshell will exit which causes the stdin descriptor
>> of the locking coprocess to be closed, ultimatively leading to release
>> of the lock.
>>
>> Comments, opinions or alternate suggestions, especially something which
>> would work with a stock /bin/sh very much appreciated.
>
> u don;t wanna wait but you use *lock* :P

u assumption wrong :-) --- the point of this exercise is obviously to ensure
that the shell waits until the lock is free (ie, not used by the
possibly concurrently running other process also manipulating the same,
shared resources).

Re: temporarily holding a lock in bash

<up59J.54469$3p3.49780@fx16.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16713&group=comp.unix.programmer#16713

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
Newsgroups: comp.unix.programmer
From: branimir.maksimovic@icloud.com (Branimir Maksimovic)
Subject: Re: temporarily holding a lock in bash
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
<xrL8J.69841$2B4.52331@fx04.iad>
<87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 44
Message-ID: <up59J.54469$3p3.49780@fx16.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Tue, 12 Oct 2021 01:20:26 UTC
Organization: usenet-news.net
Date: Tue, 12 Oct 2021 01:20:26 GMT
X-Received-Bytes: 2810
 by: Branimir Maksimovic - Tue, 12 Oct 2021 01:20 UTC

On 2021-10-11, Rainer Weikusat <rweikusat@talktalk.net> wrote:
> Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
>> On 2021-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>> coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
>>> read x <&${COPROC[0]}
>>> ----
>>>
>>> The corpoc command executes a shell command in a forked shell without
>>> waiting for it. Stdin and stdout of the coprocess are connected to pipes
>>> whose file descriptors are available as member 0 and 1 of an array, by
>>> default named COPROC.
>>>
>>> The command used here acquires an exclusive lock on the file passed as
>>> argument to -w and then execs another command (which inherits the
>>> lock). In this case, this other command writes a \n terminated string to
>>> its stdout and then reads from its stdin until an EOF is encountered
>>> which causes it to terminate, implicitly releasing the lock.
>>>
>>> The parent shell will remained blocked in the read until it has read the
>>> line written by the lock-keeper command. This means execution of the
>>> main script will be paused until the lock could be acquired. The two
>>> lines above are part of a shell function defined as ()-delimited
>>> block. The function will thus run in a forked subshell. Upon return of
>>> the function, the subhshell will exit which causes the stdin descriptor
>>> of the locking coprocess to be closed, ultimatively leading to release
>>> of the lock.
>>>
>>> Comments, opinions or alternate suggestions, especially something which
>>> would work with a stock /bin/sh very much appreciated.
>>
>> u don;t wanna wait but you use *lock* :P
>
> u assumption wrong :-) --- the point of this exercise is obviously to ensure
> that the shell waits until the lock is free (ie, not used by the
> possibly concurrently running other process also manipulating the same,
> shared resources).
Why do you need a lock? It is only need when other processes are not
under you control?

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Re: temporarily holding a lock in bash

<87v9228fin.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16714&group=comp.unix.programmer#16714

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: temporarily holding a lock in bash
Date: Tue, 12 Oct 2021 15:49:20 +0100
Lines: 21
Message-ID: <87v9228fin.fsf@doppelsaurus.mobileactivedefense.com>
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
<xrL8J.69841$2B4.52331@fx04.iad>
<87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>
<up59J.54469$3p3.49780@fx16.iad>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net ZUUaTD0jBBdg6KslS+XEuwEfEjvl2oj2oPyQ1C5ZMD61wAslE=
Cancel-Lock: sha1:5pNu2y20UFnjzASxndydZ16UnnM= sha1:Dajsld6HfSLW3G8X0U/oK2l9dPU=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Tue, 12 Oct 2021 14:49 UTC

Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
> On 2021-10-11, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>> Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
>>> On 2021-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>>> coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
>>>> read x <&${COPROC[0]}
>>>> ----

[...]

>>> u don;t wanna wait but you use *lock* :P
>>
>> u assumption wrong :-) --- the point of this exercise is obviously to ensure
>> that the shell waits until the lock is free (ie, not used by the
>> possibly concurrently running other process also manipulating the same,
>> shared resources).
> Why do you need a lock? It is only need when other processes are not
> under you control?

Non-atomic modification of some set of files by two possibly
concurrently running processes.

Re: temporarily holding a lock in bash

<WWm9J.48986$6u6.46335@fx03.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16715&group=comp.unix.programmer#16715

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx03.iad.POSTED!not-for-mail
Newsgroups: comp.unix.programmer
From: branimir.maksimovic@icloud.com (Branimir Maksimovic)
Subject: Re: temporarily holding a lock in bash
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
<xrL8J.69841$2B4.52331@fx04.iad>
<87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>
<up59J.54469$3p3.49780@fx16.iad>
<87v9228fin.fsf@doppelsaurus.mobileactivedefense.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 30
Message-ID: <WWm9J.48986$6u6.46335@fx03.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Tue, 12 Oct 2021 21:16:38 UTC
Organization: usenet-news.net
Date: Tue, 12 Oct 2021 21:16:38 GMT
X-Received-Bytes: 1927
 by: Branimir Maksimovic - Tue, 12 Oct 2021 21:16 UTC

On 2021-10-12, Rainer Weikusat <rweikusat@talktalk.net> wrote:
> Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
>> On 2021-10-11, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>> Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
>>>> On 2021-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>>>> coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
>>>>> read x <&${COPROC[0]}
>>>>> ----
>
> [...]
>
>>>> u don;t wanna wait but you use *lock* :P
>>>
>>> u assumption wrong :-) --- the point of this exercise is obviously to ensure
>>> that the shell waits until the lock is free (ie, not used by the
>>> possibly concurrently running other process also manipulating the same,
>>> shared resources).
>> Why do you need a lock? It is only need when other processes are not
>> under you control?
>
> Non-atomic modification of some set of files by two possibly
> concurrently running processes.
What's problem to run them sequentually? AS if you don't have two
disks?

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Re: temporarily holding a lock in bash

<87r1cq7xah.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16716&group=comp.unix.programmer#16716

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: temporarily holding a lock in bash
Date: Tue, 12 Oct 2021 22:23:02 +0100
Lines: 28
Message-ID: <87r1cq7xah.fsf@doppelsaurus.mobileactivedefense.com>
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
<xrL8J.69841$2B4.52331@fx04.iad>
<87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>
<up59J.54469$3p3.49780@fx16.iad>
<87v9228fin.fsf@doppelsaurus.mobileactivedefense.com>
<WWm9J.48986$6u6.46335@fx03.iad>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net JLltr8pRkBI1oMiWmKMOog5ocBiOFLTEt552oQzQg4gUlR1MI=
Cancel-Lock: sha1:03BGP7ot8HhSJ/QtmpZ50tYmJvU= sha1:qg0LmuZwlkXr6zcmjG6PDWPkFmo=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Tue, 12 Oct 2021 21:23 UTC

Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
> On 2021-10-12, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>> Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
>>> On 2021-10-11, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>>> Branimir Maksimovic <branimir.maksimovic@icloud.com> writes:
>>>>> On 2021-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>>>>> coproc lock -g surictrl -m 0660 -w $SURI_LOCK lock-keeper
>>>>>> read x <&${COPROC[0]}
>>>>>> ----
>>
>> [...]
>>
>>>>> u don;t wanna wait but you use *lock* :P
>>>>
>>>> u assumption wrong :-) --- the point of this exercise is obviously to ensure
>>>> that the shell waits until the lock is free (ie, not used by the
>>>> possibly concurrently running other process also manipulating the same,
>>>> shared resources).
>>> Why do you need a lock? It is only need when other processes are not
>>> under you control?
>>
>> Non-atomic modification of some set of files by two possibly
>> concurrently running processes.
> What's problem to run them sequentually? AS if you don't have two
> disks?

They are being forced to run sequentially if both of them attempt to
modify the same set of files at the same time.

Re: temporarily holding a lock in bash

<slrnsmebmg.3go.jj@iridium.wf32df>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16717&group=comp.unix.programmer#16717

  copy link   Newsgroups: comp.unix.programmer
Path: rocksolid2!i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jj@franjam.org.uk (Jim Jackson)
Newsgroups: comp.unix.programmer
Subject: Re: temporarily holding a lock in bash
Date: Wed, 13 Oct 2021 19:09:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <slrnsmebmg.3go.jj@iridium.wf32df>
References: <87y270r5ge.fsf@doppelsaurus.mobileactivedefense.com>
<xrL8J.69841$2B4.52331@fx04.iad>
<87czobzku8.fsf@doppelsaurus.mobileactivedefense.com>
<up59J.54469$3p3.49780@fx16.iad>
<87v9228fin.fsf@doppelsaurus.mobileactivedefense.com>
<WWm9J.48986$6u6.46335@fx03.iad>
<87r1cq7xah.fsf@doppelsaurus.mobileactivedefense.com>
Injection-Date: Wed, 13 Oct 2021 19:09:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b9b96a7c4e814dc9e87b6ab036878e23";
logging-data="5784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AS1THymP/CKqg5pidRaZnyWl19S1iLEc="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:PE7o+TWOiunxLFBcdwjxDWYUjrc=
 by: Jim Jackson - Wed, 13 Oct 2021 19:09 UTC

On 2021-10-12, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>>>>
>>>>> u assumption wrong :-) --- the point of this exercise is obviously to ensure
>>>>> that the shell waits until the lock is free (ie, not used by the
>>>>> possibly concurrently running other process also manipulating the same,
>>>>> shared resources).
>>>> Why do you need a lock? It is only need when other processes are not
>>>> under you control?
>>>
>>> Non-atomic modification of some set of files by two possibly
>>> concurrently running processes.
>> What's problem to run them sequentually? AS if you don't have two
>> disks?
>
> They are being forced to run sequentially if both of them attempt to
> modify the same set of files at the same time.

I admire your patience in bothering to explain what should be obvious!
I'd expect such non-understanding if this was a MSDOS group :-)

Needless to say I found your solution interesting.
Jim

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor