윈도우 프로그램(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 라이브러리를 사용하여 프로세스를 실행하고 종료하며, 타임아웃이나 오류가 발생할 경우에도 적절하게 처리합니다.

위탁 수하물 무게 규정에 대한 상세 설명

위탁 수하물 무게 규정에 대한 상세 설명 위탁 수하물 무게 규정이란? 항공 여행 시 위탁 수하물(기내에 직접 가지고 타지 않고 비행기 화물칸에 실리는 짐)의 무게를 제한하는 규정입니다. 일반적으로 항공권 종류, 노선, 항공사에 따라 무료로 부칠 수 있...