Help please: exec() fails with posix_spawn error

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 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

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).

1 Like

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

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

1 Like

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.

1 Like

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

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

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.

2 Likes

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:

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)
1 Like

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!

1 Like

Thank you for trying! :blue_heart:

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