윈도우 프로그램(windows program)의 '응답없음'을 찾는 프로그램 소스코드(source code)

윈도우 프로그램(windows program)의 '응답없음'을 찾는 프로그램 소스코드(source code) 

'응답없음'을 찾는 프로그램 소스코드

"응답없음"을 찾는 프로그램의 소스 코드를 알아보겠습니다. 이 코드는 Python으로 작성되었습니다. 이 프로그램은 사용자로부터 탐색할 폴더를 입력받고, 해당 폴더 내의 모든 실행 파일을 검사하여 "응답없음" 상태인 프로그램을 찾습니다.

import os

import psutil

def find_not_responding_processes(folder_path):

    # 입력한 폴더 경로 내의 모든 실행 파일 검색

    executable_files = [file for file in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, file))]    

    not_responding_processes = []

    for executable in executable_files:

        try:

            full_path = os.path.join(folder_path, executable)

            process = psutil.Popen(full_path)

            process.wait(timeout=10)  # 최대 10초까지만 기다림 (응답없음 확인용)

            

            if process.poll() is None:  # 실행이 끝나지 않았으면 응답없음

                not_responding_processes.append(full_path)

                

            process.terminate()  # 프로세스 종료

        except psutil.TimeoutExpired:

            process.terminate()  # 타임아웃 발생 시 프로세스 강제 종료

        except Exception as e:

            print(f"Error occurred for {executable}: {e}")

    return not_responding_processes


if __name__ == "__main__":

    folder_path = input("응답없음을 찾을 폴더 경로를 입력하세요: ")

    not_responding_list = find_not_responding_processes(folder_path)

    

    if not_responding_list:

        print("다음 프로그램들이 응답없음 상태입니다:")

        for process in not_responding_list:

            print(process)

    else:

        print("응답없음 상태인 프로그램이 없습니다.")

위 코드를 사용하면 사용자가 입력한 폴더 내의 실행 파일을 검사하여 응답없음 상태인 프로그램을 찾을 수 있습니다. 이 코드는 psutil 라이브러리를 사용하여 프로세스를 실행하고 종료하며, 타임아웃이나 오류가 발생할 경우에도 적절하게 처리합니다.

태풍 풀라산(PULASAN) 영향과 이동 경로

태풍 풀라산(PULASAN) 영향과 이동 경로 태풍 풀라산(PULASAN)은 현재 한반도에 큰 영향을 미치고 있습니다. 이 태풍은 강력한 비와 바람을 동반하며, 여러 기상 변화와 위험을 초래할 것으로 예상됩니다. 1. 태풍의 한반도 영향 태풍 풀...