Engineering/Mac

posix_spawn failed in Mac 해결

부스 boos 2023. 11. 15. 17:32
728x90

 Mac 에서 실행되던 java 프로그램에서 갑자기 "posix_spawn failed" 오류가 나왔는데,  외부 명령어('ls 파일명')을 실행하는데, 프로세스 생성이 실패한 듯하다. 그리고 또다른 현상은 CRT 같은 터미널 프로그램으로 접근이 안된다.

2023-11-01 10:09:34.331 [scheduledExecutorService-1] INFO  [com.exmaple.testapp.logic.util.CommandUtil.execute:105] - command:ls /Users/usre1/test.app/Payload IOException
java.io.IOException: Failed to execute. command: ls /Users/user1/test.app/Payload, result:
        at com.exmaple.testapp.logic.util.CommandUtil.execute(CommandUtil.java:106)
        at com.exmaple.testapp.logic.service.BuildService.getValueForFrameWork(BuildService.java:115)
        at com.exmaple.testapp.logic.ScheduledTask.lambda$analyze$0(ScheduledTask.java:101)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
        at com.exmaple.testapp.logic.task.ScheduledTask.process(ScheduledTask.java:99)
        at jdk.internal.reflect.GeneratedMethodAccessor149.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

Caused by: java.io.IOException: Cannot run program "ls" (in directory "."): error=0, posix_spawn failed

 

 콘솔에서는 당연히 접근이 되는데,  오류 메시지를 찾아보면 OS 에서 프로세스를 생성을 못해서 나오는 오류이니  해결 방법은 reboot 밖에 없다.

 "posix_spawn failed" 는 좀비 프로세스 증가가 원인이라고 하는데, 빨리 서비스를 해야하는 상황이라 당시 시스템 상태를 확인할 수가 없었으니 더이상 분석이 안된다.

 

참고

https://gist.github.com/jamesstout/4546975

 

Xcode/clang: error: unable to execute command: posix_spawn failed - How to check for zombie processes on Mac OS X

Xcode/clang: error: unable to execute command: posix_spawn failed - How to check for zombie processes on Mac OS X - find_zombies.sh

gist.github.com

 

https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/posix_spawn.2.html

 

Mac OS X Manual Page For posix_spawn(2)

POSIX_SPAWN(2) BSD System Calls Manual POSIX_SPAWN(2) NAME posix_spawn posix_spawnp -- spawn a process SYNOPSIS #include int posix_spawn(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t

developer.apple.com