Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4651c3f8 authored by Prashanth Swaminathan's avatar Prashanth Swaminathan
Browse files

Set child process name with child zygote args

When forking zygote processes, 'forkSimpleApps' may process multiple
simple apps in the command buffer at once. However, the parsed zygote
arguments are computed based on the first app in the command buffer,
which can lead to all launched processes being assigned the same name.

Move the setting of the child process name into childMain and use the
arguments from it's local ZygoteArguments for the appropriate name.

Bug: 305970538
Test: Verified aosp_cf_riscv64_phone correctly uses unique process names
and PIDs match intended name.
Change-Id: I0febc49649b0ede4c07898b47b0ebe6ac37e7057

Change-Id: I64b2644ffb8ee75043623222b48fba8f2cfc5f08
parent 98dc75f3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -868,6 +868,11 @@ public final class Zygote {
                                 args.mPkgDataInfoList, args.mAllowlistedDataInfoList,
                                 args.mBindMountAppDataDirs, args.mBindMountAppStorageDirs);

            // While `specializeAppProcess` sets the thread name on the process's main thread, this
            // is distinct from the app process name which appears in stack traces, as the latter is
            // sourced from the argument buffer of the Process class. Set the app process name here.
            Zygote.setAppProcessName(args, TAG);

            Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

            return ZygoteInit.zygoteInit(args.mTargetSdkVersion,
+0 −1
Original line number Diff line number Diff line
@@ -296,7 +296,6 @@ class ZygoteConnection {
                    } else {
                        // child; result is a Runnable.
                        zygoteServer.setForkChild();
                        Zygote.setAppProcessName(parsedArgs, TAG);  // ??? Necessary?
                        return result;
                    }
                }