Skip to contentSkip to conversation

toolchain: generate check-headers program under $(BUILD_DIR)

PATCH New unixmania at gmail.com 3 participants 7 messages Sep 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

From: Carlos Santos <[email protected]>

Some installations mount /tmp with the 'noexec' option, which prevents running the program generated there to check the kernel headers.

Avoid the problem by generating the program under $(BUILD_DIR), passed as the first argument to check-kernel-headers.sh.

---
CC: Cerem Cem ASLAN <[email protected]>
CC: Thomas Petazzoni <[email protected]>

---
 package/linux-headers/linux-headers.mk               |  1 +
 support/scripts/check-kernel-headers.sh              | 12 ++++++------
 toolchain/helpers.mk                                 |  9 ++++-----
 .../toolchain-external/pkg-toolchain-external.mk     |  1 +
 4 files changed, 12 insertions(+), 11 deletions(-)
package/linux-headers/linux-headers.mk +1 -0
index 46f270a0e1..676c8c44ea 100644
@@ -133,6 +133,7 @@ endef
 ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_AS_KERNEL)$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)$(BR2_KERNEL_HEADERS_CUSTOM_GIT),y)
 define LINUX_HEADERS_CHECK_VERSION
 	$(call check_kernel_headers_version,\
+		$(BUILD_DIR),\
 		$(STAGING_DIR),\
 		$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)))
 endef
support/scripts/check-kernel-headers.sh +6 -6
index a8cca78b27..cbf71e0f23 100755
@@ -1,14 +1,17 @@
 #!/bin/sh
 
-SYSROOT="${1}"
+BUILDDIR="${1}"
+SYSROOT="${2}"
 # Make sure we have enough version components
-HDR_VER="${2}.0.0"
+HDR_VER="${3}.0.0"
 
 HDR_M="${HDR_VER%%.*}"
 HDR_V="${HDR_VER#*.}"
 HDR_m="${HDR_V%%.*}"
 
-EXEC="$(mktemp -t check-headers.XXXXXX)"
+EXEC="$(mktemp -p "${BUILDDIR}" -t .check-headers.XXXXXX)"
+
+trap 'rm -f "${EXEC}"' EXIT
 
 # We do not want to account for the patch-level, since headers are
 # not supposed to change for different patchlevels, so we mask it out.
@@ -36,6 +39,3 @@ int main(int argc __attribute__((unused)),
 _EOF_
 
 "${EXEC}"
-ret=${?}
-rm -f "${EXEC}"
-exit ${ret}
toolchain/helpers.mk +4 -5
index 86d945a5b1..6a4f7223c8 100644
@@ -158,13 +158,12 @@ copy_toolchain_sysroot = \
 # Check the specified kernel headers version actually matches the
 # version in the toolchain.
 #
-# $1: sysroot directory
-# $2: kernel version string, in the form: X.Y
+# $1: build directory
+# $2: sysroot directory
+# $3: kernel version string, in the form: X.Y
 #
 check_kernel_headers_version = \
-	if ! support/scripts/check-kernel-headers.sh $(1) $(2); then \
-		exit 1; \
-	fi
+	support/scripts/check-kernel-headers.sh $(1) $(2) $(3)
 
 #
 # Check the specific gcc version actually matches the version in the
toolchain/toolchain-external/pkg-toolchain-external.mk +1 -0
index c3ddff263f..c00211d59c 100644
@@ -531,6 +531,7 @@ define $(2)_CONFIGURE_CMDS
 	$$(Q)$$(call check_unusable_toolchain,$$(TOOLCHAIN_EXTERNAL_CC))
 	$$(Q)SYSROOT_DIR="$$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC))" ; \
 	$$(call check_kernel_headers_version,\
+		$$(BUILD_DIR)\
 		$$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC)),\
 		$$(call qstrip,$$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \
 	$$(call check_gcc_version,$$(TOOLCHAIN_EXTERNAL_CC),\
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

Carlos, All,

On 2019-09-22 22:05 -0300, unixmania at gmail.com spake thusly:

Quoted 4 lines

From: Carlos Santos <[email protected]>

Some installations mount /tmp with the 'noexec' option, which prevents running the program generated there to check the kernel headers.

I'm rather surprised that check-headers is the nly thing broken in that case... :-/

Alternatively, we should probably use our own TMPDIR instead, which would fix all such problems:

    diff --git a/Makefile b/Makefile
    index 82c844620a..a006149898 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -209,6 +209,11 @@ BASE_TARGET_DIR := $(BASE_DIR)/target
     HOST_DIR := $(BASE_DIR)/host
     GRAPHS_DIR := $(BASE_DIR)/graphs
     
    +export TMPDIR = $(BUILD_DIR)/.br-temp-or-whatever
    +export TMP_DIR = $(TMPDIR)
    +export TEMP_DIR = $(TMPDIR)
    +# And so on...
    +
     LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
     REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
     REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
    @@ -1016,7 +1021,7 @@ savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
     
     # staging and target directories do NOT list these as
     # dependencies anywhere else
    -$(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
    +$(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST) $(TMPDIR):
        @mkdir -p $@
     
     # outputmakefile generates a Makefile in the output directory, if using a

Doing smething like that would solve the issue globally, rather than having ad-hoc solutions everywhere this will be needed.

Quoted 4 lines

Avoid the problem by generating the program under $(BUILD_DIR), passed as the first argument to check-kernel-headers.sh.

[--SNIP--]

Quoted 12 lines
support/scripts/check-kernel-headers.sh +2 -2
index a8cca78b27..cbf71e0f23 100755
@@ -1,14 +1,17 @@
 #!/bin/sh
 
-SYSROOT="${1}"
+BUILDDIR="${1}"
+SYSROOT="${2}"
 # Make sure we have enough version components
-HDR_VER="${2}.0.0"

support/scripts/check-kernel-headers.sh line 14

Quoted 10 lines
support/scripts/check-kernel-headers.sh +4 -1
+HDR_VER="${3}.0.0"
 
 HDR_M="${HDR_VER%%.*}"
 HDR_V="${HDR_VER#*.}"
 HDR_m="${HDR_V%%.*}"
 
-EXEC="$(mktemp -t check-headers.XXXXXX)"
+EXEC="$(mktemp -p "${BUILDDIR}" -t .check-headers.XXXXXX)"
+
+trap 'rm -f "${EXEC}"' EXIT

Two things:

1. A trap on EXIT is a bashism, while this script uses /bin/sh, which is not guaranteed to be bash.

2. Why do you want to use a trap on EXIT? If there is a motivation to do so, it does not seem to be related to this change anyway, so should be done in its own patch.

Regards,
Yann E. MORIN.

Signature · 21 lines
                                        ____________
.-----------------.--------------------:       _    :------------------.
|  Yann E. MORIN  | Real-Time Embedded |    __/ )   | /"\ ASCII RIBBON |
| +33 534.541.179 | Software  Designer |  _/ - /'   | \ / CAMPAIGN     |
| +33 638.411.245 '--------------------: (_    `--, |  X  AGAINST      |
|      yann.morin (at) orange.com      |_="    ,--' | / \ HTML MAIL    |
'--------------------------------------:______/_____:------------------'


_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
#2 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

Quoted 15 lines · On Mon, Sep 23, 2019 at 5:39 AM <[email protected]> wrote:

Carlos, All,

On 2019-09-22 22:05 -0300, unixmania at gmail.com spake thusly:

Quoted 4 lines

From: Carlos Santos <[email protected]>

Some installations mount /tmp with the 'noexec' option, which prevents running the program generated there to check the kernel headers.

I'm rather surprised that check-headers is the nly thing broken in that case... :-/

Alternatively, we should probably use our own TMPDIR instead, which would fix all such problems:

Quoted 12 lines
    diff --git a/Makefile b/Makefile
    index 82c844620a..a006149898 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -209,6 +209,11 @@ BASE_TARGET_DIR := $(BASE_DIR)/target
     HOST_DIR := $(BASE_DIR)/host
     GRAPHS_DIR := $(BASE_DIR)/graphs

    +export TMPDIR = $(BUILD_DIR)/.br-temp-or-whatever
    +export TMP_DIR = $(TMPDIR)
    +export TEMP_DIR = $(TMPDIR)
    +# And so on...

That would create all temporary files under $(BUILD_DIR)/.br-temp-or-whatever, ruining the advantage of using a tmpfs mounted at /tmp, which is much faster because it's in RAM.

Quoted 46 lines
     LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
     REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
     REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
    @@ -1016,7 +1021,7 @@ savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile

     # staging and target directories do NOT list these as
     # dependencies anywhere else
    -$(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
    +$(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST) $(TMPDIR):
        @mkdir -p $@

     # outputmakefile generates a Makefile in the output directory, if using a

Doing smething like that would solve the issue globally, rather than having ad-hoc solutions everywhere this will be needed.

Quoted 4 lines

Avoid the problem by generating the program under $(BUILD_DIR), passed as the first argument to check-kernel-headers.sh.

[--SNIP--]

Quoted 12 lines
support/scripts/check-kernel-headers.sh +2 -2
index a8cca78b27..cbf71e0f23 100755
@@ -1,14 +1,17 @@
 #!/bin/sh
 
-SYSROOT="${1}"
+BUILDDIR="${1}"
+SYSROOT="${2}"
 # Make sure we have enough version components
-HDR_VER="${2}.0.0"

support/scripts/check-kernel-headers.sh line 14

Quoted 10 lines
support/scripts/check-kernel-headers.sh +4 -1
+HDR_VER="${3}.0.0"
 
 HDR_M="${HDR_VER%%.*}"
 HDR_V="${HDR_VER#*.}"
 HDR_m="${HDR_V%%.*}"
 
-EXEC="$(mktemp -t check-headers.XXXXXX)"
+EXEC="$(mktemp -p "${BUILDDIR}" -t .check-headers.XXXXXX)"
+
+trap 'rm -f "${EXEC}"' EXIT

Two things:

Quoted 2 lines

1. A trap on EXIT is a bashism, while this script uses /bin/sh, which is not guaranteed to be bash.

From the IEEE Std 1003.1, 2004 Edition
(https://pubs.opengroup.org/onlinepubs/009695399/utilities/trap.html):

"The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified using a symbolic name, without the SIG prefix [...]"

Quoted 3 lines

2. Why do you want to use a trap on EXIT? If there is a motivation to do so, it does not seem to be related to this change anyway, so should be done in its own patch.

It's a cleaner solution.

Signature · 1 line
Carlos Santos <[email protected]>
#3 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

Quoted 14 lines · On Mon, 23 Sep 2019 08:17:55 -0300 Carlos Santos <[email protected]> wrote:
Quoted 14 lines

I'm rather surprised that check-headers is the nly thing broken in that case... :-/

Alternatively, we should probably use our own TMPDIR instead, which would fix all such problems:

    diff --git a/Makefile b/Makefile
    index 82c844620a..a006149898 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -209,6 +209,11 @@ BASE_TARGET_DIR := $(BASE_DIR)/target
     HOST_DIR := $(BASE_DIR)/host
     GRAPHS_DIR := $(BASE_DIR)/graphs
Quoted 8 lines
Quoted 4 lines
    +export TMPDIR = $(BUILD_DIR)/.br-temp-or-whatever
    +export TMP_DIR = $(TMPDIR)
    +export TEMP_DIR = $(TMPDIR)
    +# And so on...  

That would create all temporary files under $(BUILD_DIR)/.br-temp-or-whatever, ruining the advantage of using a tmpfs mounted at /tmp, which is much faster because it's in RAM.

The problem indeed only occurs with temporary files that need to be *executed*. For example, gcc creates tons of temporary files in /tmp, and that works perfectly fine and shouldn't be changed. So at this point, I also tend to prefer Carlos solution to only address the check-headers case.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

In reply to Carlos Santos

Carlos, All,

On 2019-09-23 08:17 -0300, Carlos Santos spake thusly:

Quoted 21 lines · On Mon, Sep 23, 2019 at 5:39 AM <[email protected]> wrote:
Quoted 20 lines

On 2019-09-22 22:05 -0300, unixmania at gmail.com spake thusly:

Quoted 4 lines

From: Carlos Santos <[email protected]>

Some installations mount /tmp with the 'noexec' option, which prevents running the program generated there to check the kernel headers.

I'm rather surprised that check-headers is the nly thing broken in that case... :-/

Alternatively, we should probably use our own TMPDIR instead, which would fix all such problems:

    diff --git a/Makefile b/Makefile
    index 82c844620a..a006149898 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -209,6 +209,11 @@ BASE_TARGET_DIR := $(BASE_DIR)/target
     HOST_DIR := $(BASE_DIR)/host
     GRAPHS_DIR := $(BASE_DIR)/graphs
Quoted 8 lines
Quoted 4 lines
    +export TMPDIR = $(BUILD_DIR)/.br-temp-or-whatever
    +export TMP_DIR = $(TMPDIR)
    +export TEMP_DIR = $(TMPDIR)
    +# And so on...

That would create all temporary files under $(BUILD_DIR)/.br-temp-or-whatever, ruining the advantage of using a tmpfs mounted at /tmp, which is much faster because it's in RAM.

I don't know what distro mounts /tmp as a tmpfs by default. It is certainly not the case on my Ubuntu, or on Debian when I last installed one...

But yes, having all temp files in $(BUILD_DIR)/.br-temp-or-whatever would be the expected behaviour.

What I'm afraid of, is that there are (a lot of) packages that do a similar thing, and we would have to fix each of those individually. Setting a global TMPDIR would fix it once and for all.

Also, I tend to see a lot of left-over temp files in /tmp, even after a build is completed, because pacakges buildsystems often forget to cleanup properly behind them, which would eventually fill /tmp on a long-running machine like a build server. Having our own temp dir would mean it actually gets cleaned when the build dir is removed.

And anyway, for short-lived temp files, the 'slowness' is probably a false reason: the short-lived temp files will probably never actually hit the HDD (or SSD), and will only ever live in the kernel cache. And if they happen to be a bit longer-lived that they do hit torage, then they'd also probably undergo a round of IO scheduling, which will most probably postpone the actual write to long after the file is actually closed.

But I would very like to have actual numbers to prove either way.

(Doing the whole build under tmpfs is another topic, and that would probably provide an actual, measurable gain.)

There is a third alternative. Stash the following somewhere early in the build process (e.g. in check-dependencies or some such):

    if ! is_mounted_with_exec "${TMPDIR:-/tmp}"; then
        printf '%s is mounted with noexec; this is not gonna fly.\n' "${TMPDIR:-/tmp}"
        exit 1
    fi
Quoted 8 lines
Quoted 2 lines

1. A trap on EXIT is a bashism, while this script uses /bin/sh, which is not guaranteed to be bash.

From the IEEE Std 1003.1, 2004 Edition
(https://pubs.opengroup.org/onlinepubs/009695399/utilities/trap.html):

"The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified using a symbolic name, without the SIG prefix [...]"

Ah, right. It's ERR that is a bashism, my bad.

Quoted 5 lines
Quoted 3 lines

2. Why do you want to use a trap on EXIT? If there is a motivation to do so, it does not seem to be related to this change anyway, so should be done in its own patch.

It's a cleaner solution.

How is it cleaner? I would even argue that it is no longer obvious that some code is actually run at the end...

The only case where I think a trap is interesting, IMHO, is when we want to catch errors. But as this script is not 'set -e', it will always go through to the end, and thus all commands in the script will be executed.

But for a simple script like that, I fail to see the added value of a trap on EXIT...

And even though, we would want to have that in a separate patch, because it is unrelated to what the patch is initially trying to fix.

Regards,
Yann E. MORIN.

Signature · 21 lines
                                        ____________
.-----------------.--------------------:       _    :------------------.
|  Yann E. MORIN  | Real-Time Embedded |    __/ )   | /"\ ASCII RIBBON |
| +33 534.541.179 | Software  Designer |  _/ - /'   | \ / CAMPAIGN     |
| +33 638.411.245 '--------------------: (_    `--, |  X  AGAINST      |
|      yann.morin (at) orange.com      |_="    ,--' | / \ HTML MAIL    |
'--------------------------------------:______/_____:------------------'


_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
#5 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

Quoted 3 lines · On Mon, 23 Sep 2019 14:04:48 +0200 <[email protected]> wrote:

I don't know what distro mounts /tmp as a tmpfs by default. It is certainly not the case on my Ubuntu, or on Debian when I last installed one...

$ mount | grep "/tmp"
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)

Regular Fedora 30 installation.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

PATCH 1/1 toolchain: generate check-headers program under $(BUILD_DIR)

In reply to yann.morin at orange.com
Quoted 123 lines · On Mon, Sep 23, 2019 at 9:05 AM <[email protected]> wrote:

Carlos, All,

On 2019-09-23 08:17 -0300, Carlos Santos spake thusly:

Quoted 21 lines · On Mon, Sep 23, 2019 at 5:39 AM <[email protected]> wrote:
Quoted 20 lines

On 2019-09-22 22:05 -0300, unixmania at gmail.com spake thusly:

Quoted 4 lines

From: Carlos Santos <[email protected]>

Some installations mount /tmp with the 'noexec' option, which prevents running the program generated there to check the kernel headers.

I'm rather surprised that check-headers is the nly thing broken in that case... :-/

Alternatively, we should probably use our own TMPDIR instead, which would fix all such problems:

    diff --git a/Makefile b/Makefile
    index 82c844620a..a006149898 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -209,6 +209,11 @@ BASE_TARGET_DIR := $(BASE_DIR)/target
     HOST_DIR := $(BASE_DIR)/host
     GRAPHS_DIR := $(BASE_DIR)/graphs
Quoted 8 lines
Quoted 4 lines
    +export TMPDIR = $(BUILD_DIR)/.br-temp-or-whatever
    +export TMP_DIR = $(TMPDIR)
    +export TEMP_DIR = $(TMPDIR)
    +# And so on...

That would create all temporary files under $(BUILD_DIR)/.br-temp-or-whatever, ruining the advantage of using a tmpfs mounted at /tmp, which is much faster because it's in RAM.

I don't know what distro mounts /tmp as a tmpfs by default. It is certainly not the case on my Ubuntu, or on Debian when I last installed one...

But yes, having all temp files in $(BUILD_DIR)/.br-temp-or-whatever would be the expected behaviour.

What I'm afraid of, is that there are (a lot of) packages that do a similar thing, and we would have to fix each of those individually. Setting a global TMPDIR would fix it once and for all.

Also, I tend to see a lot of left-over temp files in /tmp, even after a build is completed, because pacakges buildsystems often forget to cleanup properly behind them, which would eventually fill /tmp on a long-running machine like a build server. Having our own temp dir would mean it actually gets cleaned when the build dir is removed.

And anyway, for short-lived temp files, the 'slowness' is probably a false reason: the short-lived temp files will probably never actually hit the HDD (or SSD), and will only ever live in the kernel cache. And if they happen to be a bit longer-lived that they do hit torage, then they'd also probably undergo a round of IO scheduling, which will most probably postpone the actual write to long after the file is actually closed.

But I would very like to have actual numbers to prove either way.

(Doing the whole build under tmpfs is another topic, and that would probably provide an actual, measurable gain.)

There is a third alternative. Stash the following somewhere early in the build process (e.g. in check-dependencies or some such):

    if ! is_mounted_with_exec "${TMPDIR:-/tmp}"; then
        printf '%s is mounted with noexec; this is not gonna fly.\n' "${TMPDIR:-/tmp}"
        exit 1
    fi
Quoted 8 lines
Quoted 2 lines

1. A trap on EXIT is a bashism, while this script uses /bin/sh, which is not guaranteed to be bash.

From the IEEE Std 1003.1, 2004 Edition
(https://pubs.opengroup.org/onlinepubs/009695399/utilities/trap.html):

"The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified using a symbolic name, without the SIG prefix [...]"

Ah, right. It's ERR that is a bashism, my bad.

Quoted 5 lines
Quoted 3 lines

2. Why do you want to use a trap on EXIT? If there is a motivation to do so, it does not seem to be related to this change anyway, so should be done in its own patch.

It's a cleaner solution.

How is it cleaner? I would even argue that it is no longer obvious that some code is actually run at the end...

The only case where I think a trap is interesting, IMHO, is when we want to catch errors. But as this script is not 'set -e', it will always go through to the end, and thus all commands in the script will be executed.

But for a simple script like that, I fail to see the added value of a trap on EXIT...

And even though, we would want to have that in a separate patch, because it is unrelated to what the patch is initially trying to fix.

Regards,
Yann E. MORIN.

--

                                        ____________
.-----------------.--------------------:       _    :------------------.
|  Yann E. MORIN  | Real-Time Embedded |    __/ )   | /"\ ASCII RIBBON |
| +33 534.541.179 | Software  Designer |  _/ - /'   | \ / CAMPAIGN     |
| +33 638.411.245 '--------------------: (_    `--, |  X  AGAINST      |
|      yann.morin (at) orange.com      |_="    ,--' | / \ HTML MAIL    |

'--------------------------------------:______/_____:------------------'

_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

Quoted 6 lines

This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you.

Sorry, I prefer to spend my time doing things instead of arguing about them. Go ahead and do it as you want.

Signature · 1 line
Carlos Santos <[email protected]>