Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3] pseudo-wrapper: fix console issue
@ 2016-11-23 17:36 Gaël PORTAY
  2016-11-23 18:28 ` Yann E. MORIN
  0 siblings, 1 reply; 8+ messages in thread
From: Gaël PORTAY @ 2016-11-23 17:36 UTC (permalink / raw)
  To: buildroot

Pseudo consists of:
* a client (cli),
* a server (daemon) and
* a database managed by this daemon
  which makes a relation between inode, filename, type/mode...

Without -f/-d argument, the client forks a process, sets LD_PRELOAD,
execve's the command given as argument and waits for its completion.
The LD_PRELOAD'ed library tries to connect to the daemon and spawns it
if it isn't running.

Neither the client itself nor the LD_PRELOAD'ed library waits for the
daemon to terminate. As a consequence, the daemon may still be alive
after the completion of the command executed through the client.

Under some circumstances (running build in a docker), the daemon (which
may be still alive after the build) is killed with SIGKILL, thus it
does not let it the time to properly sync its database.

The database is rendered inconsistent for the next build. In this case,
makedevs will complain about the file type/mode, see error below.

makedevs: line xx: node (...)/output/target/dev/console exists but is of wrong type

Note that this error was introduced by c85cd189.

Because the database did not have the time to sync (ie. /dev/console
record is missing), makedevs tests the existing and real /dev/console
file mode (created by the previous build) which is a regular file to
what should have been reported by pseudo, i.e. a character device.
Those two modes are different and makedevs exits with error.

To solve this issue, this patch make the wrapper control the life of
the daemon. It spawns the server before running the script inside the
pseudo context, tells it to stop with "pseudo -S", and waits for the
server to exit before the wrapper exits.

Signed-off-by: Ga?l PORTAY <gael.portay@savoirfairelinux.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/pseudo/pseudo-wrapper | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/package/pseudo/pseudo-wrapper b/package/pseudo/pseudo-wrapper
index 9c8dbdb..194c88f 100644
--- a/package/pseudo/pseudo-wrapper
+++ b/package/pseudo/pseudo-wrapper
@@ -8,7 +8,6 @@ if [ "${0##*/}" = "fakeroot" ]; then
 fi
 
 export PSEUDO_PREFIX="$(dirname "${0%/*}")"
-export PSEUDO_OPTS="-t0"
 if [ -n "${TARGET_DIR}" ]; then
     export PSEUDO_PASSWD="${TARGET_DIR}"
 fi
@@ -16,4 +15,18 @@ if [ -n "${BASE_DIR}" ]; then
     export PSEUDO_LOCALSTATEDIR="${BASE_DIR}/build/.pseudodb"
 fi
 
-exec "${0%/*}/pseudo" "${@}"
+# spawn server manually...
+"${0%/*}/pseudo" -f &
+pid="${!}"
+
+# ... run script/command...
+"${0%/*}/pseudo" "${@}"
+rc="${?}"
+
+# ... terminate server...
+"${0%/*}/pseudo" -S
+
+# ... and wait for its completion to make sure database is synced before
+# returning.
+wait "${pid}"
+exit "${rc}"
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-24 19:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-23 17:36 [Buildroot] [PATCH v3] pseudo-wrapper: fix console issue Gaël PORTAY
2016-11-23 18:28 ` Yann E. MORIN
2016-11-23 20:57   ` Thomas Petazzoni
2016-11-23 21:34     ` Yann E. MORIN
2016-11-23 21:36       ` Thomas Petazzoni
2016-11-23 21:47   ` Arnout Vandecappelle
2016-11-23 23:59     ` Gaël PORTAY
2016-11-24 19:24       ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox