bug-bash
[Top][All Lists]
Advanced

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

Re: Possible bug: Race condition when calling external commands during t


From: Bob Proulx
Subject: Re: Possible bug: Race condition when calling external commands during trap handling
Date: Thu, 3 May 2012 01:07:50 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Tillmann.Crueger@telekom.de wrote:
> I have produced the following script as a small example:

A good small example!  I do not understand the problem but I do have a
question about one of the lines in it and a comment about another.

> trap "kill $?; exit 0" INT TERM

What did you intend with "kill $?; exit 0"?  Did you mean "kill $$"
instead?

>   local text="$(date +'%Y-%m-%d %H:%M:%S') $(hostname -s) $1"

Note that GNU date can use "+%F %T" as a shortcut for "%Y-%m-%d %H:%M:%S".
It is useful to save typing.

And lastly I will comment that you are doing quite a bit inside of an
interrupt routine.  Typically in a C program it is not safe to perform
any operation that may call malloc() within an interupt service
routine since malloc isn't reentrant.  Bash is a C program and I
assume the same restriction would apply.

Bob



reply via email to

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