| 1 |
//go:build !windows |
| 2 |
|
| 3 |
/* |
| 4 |
Copyright The containerd Authors. |
| 5 |
|
| 6 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 |
you may not use this file except in compliance with the License. |
| 8 |
You may obtain a copy of the License at |
| 9 |
|
| 10 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 12 |
Unless required by applicable law or agreed to in writing, software |
| 13 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
See the License for the specific language governing permissions and |
| 16 |
limitations under the License. |
| 17 |
*/ |
| 18 |
|
| 19 |
package process |
| 20 |
|
| 21 |
import ( |
| 22 |
"context" |
| 23 |
"errors" |
| 24 |
"fmt" |
| 25 |
|
| 26 |
"github.com/containerd/console" |
| 27 |
google_protobuf "github.com/containerd/containerd/v2/pkg/protobuf/types" |
| 28 |
"github.com/containerd/errdefs" |
| 29 |
) |
| 30 |
|
| 31 |
type deletedState struct { |
| 32 |
} |
| 33 |
|
| 34 |
func (s *deletedState) Pause(ctx context.Context) error { |
| 35 |
return errors.New("cannot pause a deleted process") |
| 36 |
} |
| 37 |
|
| 38 |
func (s *deletedState) Resume(ctx context.Context) error { |
| 39 |
return errors.New("cannot resume a deleted process") |
| 40 |
} |
| 41 |
|
| 42 |
func (s *deletedState) Update(context context.Context, r *google_protobuf.Any) error { |
| 43 |
return errors.New("cannot update a deleted process") |
| 44 |
} |
| 45 |
|
| 46 |
func (s *deletedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error { |
| 47 |
return errors.New("cannot checkpoint a deleted process") |
| 48 |
} |
| 49 |
|
| 50 |
func (s *deletedState) Resize(ws console.WinSize) error { |
| 51 |
return errors.New("cannot resize a deleted process") |
| 52 |
} |
| 53 |
|
| 54 |
func (s *deletedState) Start(ctx context.Context) error { |
| 55 |
return errors.New("cannot start a deleted process") |
| 56 |
} |
| 57 |
|
| 58 |
func (s *deletedState) Delete(ctx context.Context) error { |
| 59 |
return fmt.Errorf("cannot delete a deleted process: %w", errdefs.ErrNotFound) |
| 60 |
} |
| 61 |
|
| 62 |
func (s *deletedState) Kill(ctx context.Context, sig uint32, all bool) error { |
| 63 |
return fmt.Errorf("cannot kill a deleted process: %w", errdefs.ErrNotFound) |
| 64 |
} |
| 65 |
|
| 66 |
func (s *deletedState) SetExited(status int) { |
| 67 |
// no op |
| 68 |
} |
| 69 |
|
| 70 |
func (s *deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (Process, error) { |
| 71 |
return nil, errors.New("cannot exec in a deleted state") |
| 72 |
} |
| 73 |
|
| 74 |
func (s *deletedState) Status(ctx context.Context) (string, error) { |
| 75 |
return "stopped", nil |
| 76 |
} |