|  |  | @ -22,6 +22,7 @@ os.environ['BASEDIR'] = BASEDIR | 
			
		
	
		
		
			
				
					
					|  |  |  | TOTAL_SCONS_NODES = 1005 |  |  |  | TOTAL_SCONS_NODES = 1005 | 
			
		
	
		
		
			
				
					
					|  |  |  | prebuilt = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) |  |  |  | prebuilt = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | VALGRIND = os.getenv("VALGRIND") is not None | 
			
		
	
		
		
			
				
					
					|  |  |  | # Create folders needed for msgq |  |  |  | # Create folders needed for msgq | 
			
		
	
		
		
			
				
					
					|  |  |  | try: |  |  |  | try: | 
			
		
	
		
		
			
				
					
					|  |  |  |   os.mkdir("/dev/shm") |  |  |  |   os.mkdir("/dev/shm") | 
			
		
	
	
		
		
			
				
					|  |  | @ -169,14 +170,14 @@ managed_processes = { | 
			
		
	
		
		
			
				
					
					|  |  |  |   "plannerd": "selfdrive.controls.plannerd", |  |  |  |   "plannerd": "selfdrive.controls.plannerd", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "radard": "selfdrive.controls.radard", |  |  |  |   "radard": "selfdrive.controls.radard", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "dmonitoringd": "selfdrive.monitoring.dmonitoringd", |  |  |  |   "dmonitoringd": "selfdrive.monitoring.dmonitoringd", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "ubloxd": ("selfdrive/locationd", ["./ubloxd"]), |  |  |  |   "ubloxd": ("selfdrive/locationd", ["./ubloxd"]),  # 0 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   "loggerd": ("selfdrive/loggerd", ["./loggerd"]), |  |  |  |   "loggerd": ("selfdrive/loggerd", ["./loggerd"]),  # 1 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   "logmessaged": "selfdrive.logmessaged", |  |  |  |   "logmessaged": "selfdrive.logmessaged", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "locationd": "selfdrive.locationd.locationd", |  |  |  |   "locationd": "selfdrive.locationd.locationd", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "tombstoned": "selfdrive.tombstoned", |  |  |  |   "tombstoned": "selfdrive.tombstoned", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "logcatd": ("selfdrive/logcatd", ["./logcatd"]), |  |  |  |   "logcatd": ("selfdrive/logcatd", ["./logcatd"]), | 
			
		
	
		
		
			
				
					
					|  |  |  |   "proclogd": ("selfdrive/proclogd", ["./proclogd"]), |  |  |  |   "proclogd": ("selfdrive/proclogd", ["./proclogd"]), | 
			
		
	
		
		
			
				
					
					|  |  |  |   "boardd": ("selfdrive/boardd", ["./boardd"]),   # not used directly |  |  |  |   "boardd": ("selfdrive/boardd", ["./boardd"]), | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   "pandad": "selfdrive.pandad", |  |  |  |   "pandad": "selfdrive.pandad", | 
			
		
	
		
		
			
				
					
					|  |  |  |   "ui": ("selfdrive/ui", ["./ui"]), |  |  |  |   "ui": ("selfdrive/ui", ["./ui"]), | 
			
		
	
		
		
			
				
					
					|  |  |  |   "calibrationd": "selfdrive.locationd.calibrationd", |  |  |  |   "calibrationd": "selfdrive.locationd.calibrationd", | 
			
		
	
	
		
		
			
				
					|  |  | @ -291,6 +292,18 @@ def nativelauncher(pargs, cwd): | 
			
		
	
		
		
			
				
					
					|  |  |  |   os.chmod(pargs[0], 0o700) |  |  |  |   os.chmod(pargs[0], 0o700) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   os.execvp(pargs[0], pargs) |  |  |  |   os.execvp(pargs[0], pargs) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | def valgrindlauncher(pargs, cwd): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   # exec the process | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   os.chdir(cwd) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   # Run valgrind on a process | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   command = "valgrind --leak-check=full " + pargs[0] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   output = os.popen(command) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   while True: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     s = output.read() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if s == "": | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       break | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     # print(s) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | def start_managed_process(name): |  |  |  | def start_managed_process(name): | 
			
		
	
		
		
			
				
					
					|  |  |  |   if name in running or name not in managed_processes: |  |  |  |   if name in running or name not in managed_processes: | 
			
		
	
	
		
		
			
				
					|  |  | @ -302,9 +315,17 @@ def start_managed_process(name): | 
			
		
	
		
		
			
				
					
					|  |  |  |   else: |  |  |  |   else: | 
			
		
	
		
		
			
				
					
					|  |  |  |     pdir, pargs = proc |  |  |  |     pdir, pargs = proc | 
			
		
	
		
		
			
				
					
					|  |  |  |     cwd = os.path.join(BASEDIR, pdir) |  |  |  |     cwd = os.path.join(BASEDIR, pdir) | 
			
		
	
		
		
			
				
					
					|  |  |  |     cloudlog.info("starting process %s" % name) |  |  |  |     if VALGRIND: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     running[name] = Process(name=name, target=nativelauncher, args=(pargs, cwd)) |  |  |  |       print("\nVALGRIND" * 5) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   running[name].start() |  |  |  |       print(pargs) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       print(cwd) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       running[name] = Process(name=name, target=valgrindlauncher, args=(pargs, cwd)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     else: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       cloudlog.info("starting process %s" % name) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       print(pargs) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       print(cwd) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       running[name] = Process(name=name, target=nativelauncher, args=(pargs, cwd)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     running[name].start() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | def start_daemon_process(name): |  |  |  | def start_daemon_process(name): | 
			
		
	
		
		
			
				
					
					|  |  |  |   params = Params() |  |  |  |   params = Params() | 
			
		
	
	
		
		
			
				
					|  |  | 
 |