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...@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