Refactor startup process (Fixing #90) #131
                
     Open
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Changes Overview
Added
fusefs_ll_op_init_override()as sqfs's init hook and fork inside there to make the payload child of the fuse process. Mount is guaranteed beforesqfs_ll_ops.initis called, therefore there's no need to usekeepalive_pipefor synchronization.Removed
fuse_daemonize()and thefuse_mounted()pipe-based sync logic, made FUSE run in foreground (with the-fflag). Since now the payload is the child of fuse instead of the main process, there's no reason to daemonize the fuse process. This better matches a regular application's behavior: stays in foreground when invoked, and uses tty for user interaction.Parent process now waits on the payload (
childpid) and directly returns its exit code or signal status. Exit code relating to signals likeSIGINTandSIGTERMare handled by separately.This PR potentially also solves AppImage not unmounting when running as systemd service #99. Tests with my own AppImages run as systemd services show resolved hanging behavior. However I'm not sure whether it applies to all other AppImages used as systemd service.
Here's a minimal AppRun for verifying its behavior: