[explorer/init] Support for Darwin and more BusyBox combinations
This commit is contained in:
		
					parent
					
						
							
								87f30b6053
							
						
					
				
			
			
				commit
				
					
						de1a421b68
					
				
			
		
					 1 changed files with 13 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -23,14 +23,22 @@
 | 
			
		|||
# for example at linux this value is "init" or "systemd" in most cases
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
uname_s="$(uname -s)"
 | 
			
		||||
 | 
			
		||||
case "$uname_s" in
 | 
			
		||||
case $(uname -s) in
 | 
			
		||||
    Linux)
 | 
			
		||||
        if command -v pgrep >/dev/null
 | 
			
		||||
        then
 | 
			
		||||
            # BusyBox's version of ps does not support some options.
 | 
			
		||||
            # On Linux systems, we prefer pgrep to get the name of PID1.
 | 
			
		||||
            (pgrep -P0 -l | awk '/^1[ \t]/ {print $2;}') || true
 | 
			
		||||
        else
 | 
			
		||||
            ps -o comm= -p 1 2>/dev/null || cat /proc/1/comm
 | 
			
		||||
        fi
 | 
			
		||||
    ;;
 | 
			
		||||
    FreeBSD|OpenBSD)
 | 
			
		||||
        ps -o comm= -p 1 || true
 | 
			
		||||
        ps -o comm= -p 1 2>/dev/null || true
 | 
			
		||||
    ;;
 | 
			
		||||
    Darwin)
 | 
			
		||||
        basename "$(ps -o comm= -p 1 2>/dev/null)"
 | 
			
		||||
    ;;
 | 
			
		||||
    *)
 | 
			
		||||
        # return a empty string as unknown value
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue