cloneNewTask is a version of NewTask that the clone() syscall uses. Unlike NewTask, cloneNewTask will create and return a pidFD if requested.
(ctx context.Context, cfg *TaskConfig)
| 145 | // cloneNewTask is a version of NewTask that the clone() syscall uses. |
| 146 | // Unlike NewTask, cloneNewTask will create and return a pidFD if requested. |
| 147 | func (ts *TaskSet) cloneNewTask(ctx context.Context, cfg *TaskConfig) (*Task, int32, error) { |
| 148 | var err error |
| 149 | cleanup := func() { |
| 150 | cfg.TaskImage.release(ctx) |
| 151 | cfg.Credentials.UserNamespace.DecRef(ctx) |
| 152 | cfg.FSContext.DecRef(ctx) |
| 153 | cfg.FDTable.DecRef(ctx) |
| 154 | cfg.UTSNamespace.DecRef(ctx) |
| 155 | cfg.IPCNamespace.DecRef(ctx) |
| 156 | cfg.NetworkNamespace.DecRef(ctx) |
| 157 | if cfg.MountNamespace != nil { |
| 158 | cfg.MountNamespace.DecRef(ctx) |
| 159 | } |
| 160 | } |
| 161 | if err := cfg.UserCounters.incRLimitNProc(ctx); err != nil { |
| 162 | cleanup() |
| 163 | return nil, -1, err |
| 164 | } |
| 165 | t, fd, err := ts.newTask(ctx, cfg) |
| 166 | if err != nil { |
| 167 | cfg.UserCounters.decRLimitNProc() |
| 168 | cleanup() |
| 169 | return nil, -1, err |
| 170 | } |
| 171 | return t, fd, nil |
| 172 | } |
| 173 | |
| 174 | // newTask is a helper for TaskSet.NewTask that only takes ownership of parts |
| 175 | // of cfg if it succeeds. |
no test coverage detected