Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7509315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:52:26+00:00 2026-05-29T22:52:26+00:00

I have an issue when I’m using Runtime.exec with my Android device and just

  • 0

I have an issue when I’m using Runtime.exec with my Android device and just can’t figure out why it happens…

Here is an example of the tests I did :

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Runtime runtime = Runtime.getRuntime();
        for(int i=0; i< 20; i++){
            Log.d("TESTEXEC", "EXEC N°"+i+" : BEGIN");
            try {
                Process process = runtime.exec("/system/bin/ps");
                process.getErrorStream().close();
                process.getOutputStream().close();
                process.getInputStream().close();
                process.waitFor();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            Log.d("TESTEXEC", "EXEC N°"+i+" : END");
        }
    }
}

So, basically, when this snippet works, it prints this :

EXEC N°0 : BEGIN
EXEC N°0 : END
EXEC N°1 : BEGIN
EXEC N°1 : END
...
EXEC N°19 : BEGIN
EXEC N°19 : END

But instead of that, sometimes (it looks like it’s a bit random), it just prints

EXEC N°0 : BEGIN

And everything locks…
The whole things seems to crash into the runtime.exec(“…”), and the process.getErrorStream.close() is never called.
Another strange thing : The bug always occurs on the first exec.

Here is what I get with DDMS :
DDMS

I also retrieved the /data/anr/traces.txt, but it’s not really useful :

----- pid 11489 at 2011-05-16 15:15:10 -----
Cmd line: com.testexec

DALVIK THREADS:
"main" prio=5 tid=1 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x4001d8d0 self=0xcca0
  | sysTid=11489 nice=0 sched=0/0 cgrp=unknown handle=-1345021856
  at java.lang.ProcessManager.exec(Native Method)
  at java.lang.ProcessManager.exec(ProcessManager.java:224)
  at java.lang.Runtime.exec(Runtime.java:196)
  at java.lang.Runtime.exec(Runtime.java:285)
  at java.lang.Runtime.exec(Runtime.java:218)
  at com.testexec.MainActivity.onCreate(MainActivity.java:17)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2629)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2681)
  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4641)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  at dalvik.system.NativeStart.main(Native Method)

"java.lang.ProcessManager" daemon prio=5 tid=8 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x460969f0 self=0x240f58
  | sysTid=11496 nice=0 sched=0/0 cgrp=unknown handle=2363544
  at java.lang.ProcessManager.watchChildren(Native Method)
  at java.lang.ProcessManager$1.run(ProcessManager.java:87)

"Binder Thread #2" prio=5 tid=7 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x460895a0 self=0x1248e0
  | sysTid=11495 nice=0 sched=0/0 cgrp=unknown handle=1236304
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=6 NATIVE
  | group="main" sCount=1 dsCount=0 s=N obj=0x46086cf8 self=0x143480
  | sysTid=11494 nice=0 sched=0/0 cgrp=unknown handle=1324096
  at dalvik.system.NativeStart.run(Native Method)

"Compiler" daemon prio=5 tid=5 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x46084558 self=0x144560
  | sysTid=11493 nice=0 sched=0/0 cgrp=unknown handle=1153256
  at dalvik.system.NativeStart.run(Native Method)

"JDWP" daemon prio=5 tid=4 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x460842a0 self=0x12dc10
  | sysTid=11492 nice=0 sched=0/0 cgrp=unknown handle=1152968
  at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
  | group="system" sCount=0 dsCount=0 s=N obj=0x460841e8 self=0x124d00
  | sysTid=11491 nice=0 sched=0/0 cgrp=unknown handle=1199296
  at dalvik.system.NativeStart.run(Native Method)

"HeapWorker" daemon prio=5 tid=2 VMWAIT
  | group="system" sCount=1 dsCount=0 s=N obj=0x441e2ee8 self=0x11fdd8
  | sysTid=11490 nice=0 sched=0/0 cgrp=unknown handle=1185776
  at dalvik.system.NativeStart.run(Native Method)

----- end 11489 -----

I’m kinda desesperate right now, so if anyone has an idea, I’d really appreciate it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:52:28+00:00Added an answer on May 29, 2026 at 10:52 pm

    That’s most likely the bug fixed in this Github commit. In essence, it deadlocks directly after fork() but before doing the actual exec() because somebody tried to malloc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have another issue here. Our app starts out with a tab activity. But, before
i have issue regarding Paging using filterexpression. here's the piece of code for filtering
I have an issue with SSO using the Facebook SDK for Android. The problem
i have done drag and drop using with jquery. here i have issue that
I have an issue that I've spent hours trying to figure out, but since
Have an issue with the following array... I can't navigate it using $arrayname[0]... it
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue using the PEAR libraries on Windows from PHP . Pear
I have an issue with using AWK to simply remove a field from a
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.