From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
To: Qing-wu.Li@leica-geosystems.com.cn, oss-tools@pengutronix.de,
m.felsch@pengutronix.de
Cc: bsp-development.geo@leica-geosystems.com
Subject: [OSS-Tools] [PATCH platsch V5 4/5] Platsch: always fork child process
Date: Wed, 19 Jun 2024 12:22:26 +0200 [thread overview]
Message-ID: <20240619102227.2013556-4-Qing-wu.Li@leica-geosystems.com.cn> (raw)
In-Reply-To: <20240619102227.2013556-1-Qing-wu.Li@leica-geosystems.com.cn>
When running Platsch in the background with an ampersand,
the initramfs may disappear after the rootfs is mounted.
In such cases, Platsch may fail to read the resources.
To address this, Platsch now always forks a child process
after acquiring the resources.
The chiled process keeps the DRM devices remain open
while the parent process exits with a clear status.
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
platsch.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/platsch.c b/platsch.c
index 6503066..756ba1c 100644
--- a/platsch.c
+++ b/platsch.c
@@ -119,17 +119,18 @@ int main(int argc, char *argv[])
platsch_drmDropMaster();
+ ret = fork();
+ if (ret < 0) {
+ platsch_error("failed to fork for init: %m\n");
+ } else if (ret == 0) {
+ /*
+ * in the child go to sleep to keep the drm device open
+ * and give pid 1 to init.
+ */
+ goto sleep;
+ }
+
if (pid1) {
- ret = fork();
- if (ret < 0) {
- platsch_error("failed to fork for init: %m\n");
- } else if (ret == 0) {
- /*
- * in the child go to sleep to keep the drm device open
- * and give pid 1 to init.
- */
- goto sleep;
- }
initsargv = calloc(sizeof(argv[0]), argc + 1);
if (!initsargv) {
@@ -147,6 +148,8 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
+ return EXIT_SUCCESS;
+
sleep:
platsch_redirect_stdfd();
--
2.34.1
next prev parent reply other threads:[~2024-06-19 12:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 10:22 [OSS-Tools] [PATCH platsch V5 1/5] platsch: constify draw_buffer LI Qingwu
2024-06-19 10:22 ` [OSS-Tools] [PATCH platsch V5 2/5] convert to meson build LI Qingwu
2024-06-20 12:19 ` Philipp Zabel
2024-06-23 11:46 ` LI Qingwu
2024-06-19 10:22 ` [OSS-Tools] [PATCH platsch V5 3/5] platsch: split into platsch and libplatsch LI Qingwu
2024-06-20 12:55 ` Philipp Zabel
2024-06-19 10:22 ` LI Qingwu [this message]
2024-06-19 10:22 ` [OSS-Tools] [PATCH platsch V5 5/5] Add spinner executable for boot animation and text show LI Qingwu
2024-06-20 12:46 ` Philipp Zabel
2024-06-23 11:52 ` LI Qingwu
2024-06-24 7:55 ` Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240619102227.2013556-4-Qing-wu.Li@leica-geosystems.com.cn \
--to=qing-wu.li@leica-geosystems.com.cn \
--cc=bsp-development.geo@leica-geosystems.com \
--cc=m.felsch@pengutronix.de \
--cc=oss-tools@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox