MCPcopy
hub / github.com/google/gvisor / execAsync

Method execAsync

pkg/sentry/control/proc.go:197–338  ·  view source on GitHub ↗

execAsync runs a new task, but doesn't wait for it to finish. It returns the newly created thread group and its PID. If the stdio FDs are TTYs, then a TTYFileOperations that wraps the TTY is also returned.

(args *ExecArgs)

Source from the content-addressed store, hash-verified

195// newly created thread group and its PID. If the stdio FDs are TTYs, then a
196// TTYFileOperations that wraps the TTY is also returned.
197func (proc *Proc) execAsync(args *ExecArgs) (*kernel.ThreadGroup, kernel.ThreadID, *host.TTYFileDescription, error) {
198 creds := auth.NewUserCredentials(
199 args.KUID,
200 args.KGID,
201 args.ExtraKGIDs,
202 args.Capabilities,
203 proc.Kernel.RootUserNamespace())
204
205 pidns := args.PIDNamespace
206 if pidns == nil {
207 pidns = proc.Kernel.RootPIDNamespace()
208 }
209 limitSet := args.Limits
210 if limitSet == nil {
211 limitSet = limits.NewLimitSet()
212 }
213 initArgs := kernel.CreateProcessArgs{
214 Filename: args.Filename,
215 Argv: args.Argv,
216 Envv: args.Envv,
217 WorkingDirectory: args.WorkingDirectory,
218 MountNamespace: args.MountNamespace,
219 Credentials: creds,
220 NoNewPrivs: args.NoNewPrivileges,
221 Umask: 0022,
222 Limits: limitSet,
223 MaxSymlinkTraversals: linux.MaxSymlinkTraversals,
224 UTSNamespace: proc.Kernel.RootUTSNamespace(),
225 IPCNamespace: proc.Kernel.RootIPCNamespace(),
226 ContainerID: args.ContainerID,
227 PIDNamespace: pidns,
228 Origin: kernel.OriginExec,
229 }
230 ctx := initArgs.NewContext(proc.Kernel)
231
232 if initArgs.MountNamespace == nil {
233 // Set initArgs so that 'ctx' returns the namespace.
234 initArgs.MountNamespace = proc.Kernel.GlobalInit().Leader().MountNamespace()
235 }
236 // initArgs must hold a reference on MountNamespace, which will
237 // be donated to the new process in CreateProcess.
238 initArgs.MountNamespace.IncRef()
239 mntnsCu := cleanup.Make(func() { initArgs.MountNamespace.DecRef(ctx) })
240 defer mntnsCu.Clean()
241
242 // Import file descriptors.
243 var fdTable *kernel.FDTable
244 if args.FDTable != nil {
245 fdTable = args.FDTable
246 // reference borrowed from the caller
247 } else {
248 fdTable = proc.Kernel.NewFDTable()
249 defer fdTable.DecRef(ctx)
250 }
251 initArgs.FDTable = fdTable
252
253 fdMap, execFD, err := args.unpackFiles()
254 if err != nil {

Callers 2

ExecMethod · 0.95
ExecAsyncFunction · 0.80

Calls 15

NewContextMethod · 0.95
DecRefMethod · 0.95
NewUserCredentialsFunction · 0.92
NewLimitSetFunction · 0.92
MakeFunction · 0.92
NewFDFunction · 0.92
ResolveExecutablePathFunction · 0.92
ImportFunction · 0.92
WarningfFunction · 0.92
RootUserNamespaceMethod · 0.80
RootPIDNamespaceMethod · 0.80
RootUTSNamespaceMethod · 0.80

Tested by

no test coverage detected