#NEWLINE# def clean_proc_dir( opts ) : #NEWLINE# #INDENT# '\n    Loop through jid files in the minion proc directory (default /var/cache/salt/minion/proc)\n    and remove any that refer to processes that no longer exist\n    ' #NEWLINE# for basefilename in os . listdir ( salt . minion . get_proc_dir ( opts [ 'cachedir' ] ) ) : #NEWLINE# #INDENT# fn_ = os . path . join ( salt . minion . get_proc_dir ( opts [ 'cachedir' ] ) , basefilename ) #NEWLINE# with salt . utils . fopen ( fn_ , 'rb' ) as fp_ : #NEWLINE# #INDENT# job = None #NEWLINE# try : #NEWLINE# #INDENT# job = salt . payload . Serial ( opts ) . load ( fp_ ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# if salt . utils . is_windows ( ) : #NEWLINE# #INDENT# fp_ . close ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# os . unlink ( fn_ ) #NEWLINE# continue #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# log . debug ( 'schedule.clean_proc_dir: checking job {0} for process existence' . format ( job ) ) #NEWLINE# if ( ( job is not None ) and ( 'pid' in job ) ) : #NEWLINE# #INDENT# if salt . utils . process . os_is_running ( job [ 'pid' ] ) : #NEWLINE# #INDENT# log . debug ( 'schedule.clean_proc_dir: Cleaning proc dir, pid {0} still exists.' . format ( job [ 'pid' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if salt . utils . is_windows ( ) : #NEWLINE# #INDENT# fp_ . close ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# os . unlink ( fn_ ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass