# Help please: exec() fails with posix\_spawn error

**URL:** https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374
**Category:** Coding Questions
**Created:** [May 12, 2025, 4:45am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374 "2025-05-12T04:45:06Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![AndrewS](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andrews/32/18520_2.png) [@AndrewS](https://discourse.processing.org/u/AndrewS)
#### Post date: [May 12, 2025, 4:45am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/1 "2025-05-12T04:45:07Z")

</div>

Modernising some code that currently runs slowly on a 2014 mac mini (Yosemite, Processing 3.5.4) to run on a 2017 iMac (Ventura, Processing 4.4.1). Calls to ‘exec()’ work on the 2014 machine and a 2017 Macbook Pro (Ventura), Processing 4.2) but fail on the other machines (including Mac mini M4, Sequoia, Processing 4.4.1).

The ‘exec()’ call is used to ping google to check internet availability and to execute python code to upload files to google cloud storage. I use the [Command.java](https://github.com/GoToLoop/command/blob/patch-1/src/deadpixel/command/Command.java) code of @GoToLoop (thanks!) to get return values, and for the ping call it returns the message: Cannot run program “ping”: error=0, posix\_spawn failed

The exec call fails also with a simple Process p = exec(‘ls’) call, returning a less helpful alert ‘Exception while attempting ls’

Any clues please?

I thought perhaps the Java version?

- original machine: ver 1.8.0\_331
- Macbook: ver 1.8.0\_421\_b09
- iMac: ver 1.8.0\_331\_b09
- Mac mini m4: ver 1.8.0\_451\_b10

Andrew

PS the code runs this device for an artwork: [Catch Your Breath](https://andrewstyan.com/portfolio/catch-your-breath/)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/d/a/da85fde5714c61bc5b84223fcdb67021c3b51317.jpeg)

---

<div class="post-metadata">

### Author: ![AndrewS](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andrews/32/18520_2.png) [@AndrewS](https://discourse.processing.org/u/AndrewS)
#### Post date: [May 12, 2025, 6:16am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/2 "2025-05-12T06:16:45Z")

</div>

Well, that didn’t take long. Just writing it out prompted the question: Is the problem with Processing 4.4. Answer: Yes.

By downgrading to 4.2 the exec() error disappeared. A bug in release 4.4 or 4.3?

If there is no feedback in a day or so I’ll raise an issue on Github (can’t see any similar issues).

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [May 12, 2025, 6:26am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/3 "2025-05-12T06:26:15Z")

</div>

I’ve written that so long ago for Processing 3. What a relief downgrading to 4.2 was enough! 😌

BtW, if you need to mix Java + Python, you’re better off using py5 instead: 🐍

> **[Welcome to py5! — py5 documentation](https://py5coding.org)**

---

<div class="post-metadata">

### Author: ![AndrewS](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andrews/32/18520_2.png) [@AndrewS](https://discourse.processing.org/u/AndrewS)
#### Post date: [May 12, 2025, 7:16am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/4 "2025-05-12T07:16:06Z")

</div>

Ha! And I originally wrote this code in 2016, still tweaking it 9 years later. I recall ‘gotoLoop’ popping up often when I needed help back then. Thanks!

I’ve now moved on to Unity supplemented by Python for data wrangling, so it always does my head in when I have to maintain some Processing code. Still an amazing language though and has got me (and many others) into media art.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [May 12, 2025, 7:47am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/5 "2025-05-12T07:47:01Z")

</div>

> [@AndrewS](#):
>
> And I originally wrote this code in 2016,

Oops! So you’re deadpixel then. Now I remember that I’ve forked & refactored your code. 🥴

> [@AndrewS](#):
>
> I’ve now moved on to Unity supplemented by Python for data wrangling,

Well. whenever you need to use Processing and Python together, try out py5 too. ☕

---

<div class="post-metadata">

### Author: ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)
#### Post date: [May 12, 2025, 8:56am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/6 "2025-05-12T08:56:27Z")

</div>

Could you try 4.4.3 to see if this fixes the issues. We’ve had similar reports earlier and I’d love to know if my changes fixed it.

> <https://github.com/processing/processing4/issues/1044>
>
> \### Most appropriate sub-area of Processing 4?
> 
> Accessibility
> 
> \### Processing ve…rsion
> 
> 4.1.1
> 
> \### Operating system
> 
> MacOSX
> 
> \### Steps to reproduce this
> 
> Version: Processing 4.4.1
> OS: macOS \[specify your version, for example, 15.1.1 (24B91)\]
> 
> Problem:
> In Processing 4.4.1, the say command (text-to-speech via macOS) does not work, causing an error:
> 
> Copy
> Cannot run program "say": error=0, posix\_spawn failed
> I tried all the suggested solutions (changing permissions, alternative methods via osascript), but the problem persists.
> 
> Solution:
> Reverted to Processing 4.3.4 - the say function works correctly.
> 
> Suggestions:
> Add a check for say compatibility with new macOS versions in Processing 4.4.1+.
> 
> Specify in the documentation that speech synthesis on macOS 15+ may require a rollback to 4.3.4.
> 
> Consider alternative methods of voicing (for example, via FreeTTS or system APIs).
> 
> Context:
> 
> Java version: 17.0.14
> 
> Tested on: Mac mini (M1/M2)
> 
> \### snippet
> 
> \`\`\`processing
> 
> // Paste your code below :)
> 
> void setup() {
> 
> }
> 
> void draw() {
> 
> }
> \`\`\`
> 
> 
> \### Additional context
> 
> \_No response\_
> 
> \### Would you like to work on the issue?
> 
> Is this within my capabilities?

---

<div class="post-metadata">

### Author: ![AndrewS](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andrews/32/18520_2.png) [@AndrewS](https://discourse.processing.org/u/AndrewS)
#### Post date: [May 13, 2025, 1:22am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/7 "2025-05-13T01:22:29Z")

</div>

Yes. This fixes it for my usage: exec(“ping”) and exec(“python …”)

Tested on iMac (2017, Ventura 13.7.5) and Mac Mini M4 (2024, Sequoia 15.4.1).

**However,** the code won’t export if ‘embed Java’ is selected regardless of OS version. I generally embed, not sure why :). It does export without embedding java, and does export with 4.4.1. This is with OpenJDK 17 installed. With vanilla ‘hello world’ code the following error is returned:

```auto
java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.orElseThrow(Unknown Source)
	at processing.mode.java.JavaBuild.exportApplication(JavaBuild.java:756)
	at processing.mode.java.JavaBuild.exportApplication(JavaBuild.java:600)
	at processing.mode.java.JavaMode.handleExportApplication(JavaMode.java:184)
	at processing.mode.java.JavaEditor.lambda$handleExportApplication$19(JavaEditor.java:495)
	at processing.app.ui.ExportPrompt.trigger(ExportPrompt.java:345)
	at processing.mode.java.JavaEditor.handleExportApplication(JavaEditor.java:504)
	at processing.mode.java.JavaEditor.lambda$buildFileMenu$0(JavaEditor.java:233)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.doClick(Unknown Source)
	at java.desktop/com.apple.laf.ScreenMenuItem.actionPerformed(Unknown Source)
	at java.desktop/java.awt.MenuItem.processActionEvent(Unknown Source)
	at java.desktop/java.awt.MenuItem.processEvent(Unknown Source)
	at java.desktop/java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.MenuComponent.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

```

---

<div class="post-metadata">

### Author: ![AndrewS](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andrews/32/18520_2.png) [@AndrewS](https://discourse.processing.org/u/AndrewS)
#### Post date: [May 13, 2025, 1:48am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/8 "2025-05-13T01:48:14Z")

</div>

> [@GoToLoop](#):
>
> Oops! So you’re deadpixel then. Now I remember that I’ve forked & refactored your code. 🥴

Nah, thats not me. I was referring to the code where I used command.java. Written in 2016 and added command.java in 2024.

callPython() looks intriguing!

---

<div class="post-metadata">

### Author: ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)
#### Post date: [May 13, 2025, 5:54am UTC](https://discourse.processing.org/t/help-please-exec-fails-with-posix-spawn-error/46374/9 "2025-05-13T05:54:54Z")

</div>

Thank you for trying! 💙

I’ll try to fix the other error some time later for 4.4.4, I have a hunch as to what happened there.
