From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
To: Qing-wu.Li@leica-geosystems.com.cn,
jie.gu@leica-geosystems.com.cn, oss-tools@pengutronix.de,
m.felsch@pengutronix.de
Cc: bsp-development.geo@leica-geosystems.com
Subject: [OSS-Tools] [PATCH platsch V6 RESEND 4/5] Platsch: always fork child process
Date: Thu, 4 Jul 2024 11:46:29 +0200 [thread overview]
Message-ID: <20240704094630.1216852-4-Qing-wu.Li@leica-geosystems.com.cn> (raw)
In-Reply-To: <20240704094630.1216852-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-07-04 9:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 9:46 [OSS-Tools] [PATCH platsch V6 RESEND 1/5] platsch: constify draw_buffer LI Qingwu
2024-07-04 9:46 ` [OSS-Tools] [PATCH platsch V6 RESEND 2/5] convert to meson build LI Qingwu
2024-07-04 9:46 ` [OSS-Tools] [PATCH platsch V6 RESEND 3/5] platsch: split into platsch and libplatsch LI Qingwu
2024-07-04 9:46 ` LI Qingwu [this message]
2024-07-04 9:46 ` [OSS-Tools] [PATCH platsch V6 RESEND 5/5] Add spinner executable for boot animation and text show LI Qingwu
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=20240704094630.1216852-4-Qing-wu.Li@leica-geosystems.com.cn \
--to=qing-wu.li@leica-geosystems.com.cn \
--cc=bsp-development.geo@leica-geosystems.com \
--cc=jie.gu@leica-geosystems.com.cn \
--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