Sign inSign up

jonstonchan/exit

By jonstonchan

•Updated over 2 years ago

Exits with specified exit code

Image
0

10K+

jonstonchan/exit repository overview

⁠Tags

  • 0, true
  • 1, false
  • 2, 3, 4, ..., 255

There is no latest tag

⁠Usage

⁠Publish pre-built static sites to GitLab Pages through CI pipelines

pages:
  stage: deploy
  image: jonstonchan/exit:true
  script: _
  artifacts:
    paths:
      - public/

⁠Cause Docker to exit with a specified exit code

docker run --rm jonstonchan/exit:127; echo $?

job:
  image: jonstonchan/exit:127
  status:
    success: [0, 127]
    warning: [63]

* invalid code block at the time of writing

Relevant GitLab issues:

⁠Build

nasm -f bin -d exit_code=$exit_code -o e exit.asm

⁠exit.asm template (based on this Stack Exchange response⁠)

BITS 64
  org 0x400000

ehdr:           ; Elf64_Ehdr
  db 0x7f, "ELF", 2, 1, 1, 0 ; e_ident
  times 8 db 0
  dw  2         ; e_type
  dw  0x3e      ; e_machine
  dd  1         ; e_version
  dq  _start    ; e_entry
  dq  phdr - $$ ; e_phoff
  dq  0         ; e_shoff
  dd  0         ; e_flags
  dw  ehdrsize  ; e_ehsize
  dw  phdrsize  ; e_phentsize
  dw  1         ; e_phnum
  dw  0         ; e_shentsize
  dw  0         ; e_shnum
  dw  0         ; e_shstrndx
  ehdrsize  equ  $ - ehdr

phdr:           ; Elf64_Phdr
  dd  1         ; p_type
  dd  5         ; p_flags
  dq  0         ; p_offset
  dq  $$        ; p_vaddr
  dq  $$        ; p_paddr
  dq  filesize  ; p_filesz
  dq  filesize  ; p_memsz
  dq  0x1000    ; p_align
  phdrsize  equ  $ - phdr

_start:
  lea  eax, [rdi+60]     ; rax = 60 = SYS_exit, using a 3-byte instruction: base+disp8 addressing mode
  %ifn exit_code = 0
    mov  dil, exit_code  ; int status = exit_code
  %endif
  syscall                ; native 64-bit system call

filesize  equ  $ - $$

Tag summary

Content type

Image

Digest

sha256:3e596a9ef…

Size

145 Bytes

Last updated

over 2 years ago

docker pull jonstonchan/exit:true