mirror of
				https://source.quilibrium.com/quilibrium/ceremonyclient.git
				synced 2025-10-31 23:17:27 +00:00 
			
		
		
		
	fix poor_man_cd race conditions (#52)
This commit is contained in:
		
							parent
							
								
									53d4664ab7
								
							
						
					
					
						commit
						2b232a8e2f
					
				| @ -2,20 +2,40 @@ | |||||||
| 
 | 
 | ||||||
| start_process() { | start_process() { | ||||||
|     GOEXPERIMENT=arenas go run ./... & |     GOEXPERIMENT=arenas go run ./... & | ||||||
|     process_pid=$! |     local process_pid=$! | ||||||
|     child_process_pid=$(pgrep -P $process_pid) |     local child_process_pid=$(pgrep -P $process_pid) | ||||||
|  |     echo "Process started with PID $process_pid and child PID $child_process_pid" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| is_process_running() { | is_process_running() { | ||||||
|  |     local process_pid=$(ps -ef | grep "exe/node" | grep -v grep | awk '{print $2}') | ||||||
|     ps -p $process_pid > /dev/null 2>&1 |     ps -p $process_pid > /dev/null 2>&1 | ||||||
|     return $? |     return $? | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| kill_process() { | kill_process() { | ||||||
|     kill $process_pid |     local process_count=$(ps -ef | grep "exe/node" | grep -v grep | wc -l) | ||||||
|     kill $child_process_pid |     local process_pids=$(ps -ef | grep "exe/node" | grep -v grep | awk '{print $2}' | xargs) | ||||||
|  | 
 | ||||||
|  |     if [ $process_count -gt 0 ]; then | ||||||
|  |         echo "killing processes $process_pids" | ||||||
|  |         kill $process_pids | ||||||
|  | 
 | ||||||
|  |         local child_process_count=$(pgrep -P $process_pids | wc -l) | ||||||
|  |         local child_process_pids=$(pgrep -P $process_pids | xargs) | ||||||
|  |         if [ $child_process_count -gt 0 ]; then | ||||||
|  |             echo "killing child processes $child_process_pids" | ||||||
|  |             kill $child_process_pids | ||||||
|  |         else | ||||||
|  |             echo "no child processes running" | ||||||
|  |         fi | ||||||
|  |     else | ||||||
|  |         echo "no processes running" | ||||||
|  |     fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | kill_process | ||||||
|  | 
 | ||||||
| start_process | start_process | ||||||
| 
 | 
 | ||||||
| while true; do | while true; do | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Ahmed Bayoumy
						Ahmed Bayoumy