Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return exit status of process when attaching to process #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion commands/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ func (command *Attach) Execute(maybeHandle []string) error {
})
failIf(err)

_, err = process.Wait()
status, err := process.Wait()
failIf(err)
os.Exit(status)

return nil
}
14 changes: 14 additions & 0 deletions test/attach.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bats

load test_helper

@test "it returns exit code from attach" {
handle=$(gaol create)
assert_success

process_id=$(gaol run -c 'sh -c "sleep 1; exit 42"' $handle)
assert_success

run gaol attach $handle -p $process_id
assert_equal $status 42
}
6 changes: 3 additions & 3 deletions test/create.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ load test_helper
}

@test "a created container bind mount is read-write by default" {
handle=$(gaol create -m .:/tmp/cmnt)
handle=$(gaol create -m /bin:/tmp/cmnt)
assert_success

run gaol run -a -c "/bin/sh -c 'cat /proc/self/mounts | grep /tmp/cmnt'" $handle
Expand All @@ -34,7 +34,7 @@ load test_helper
}

@test "a created container can have read-only bind mounts" {
handle=$(gaol create -m .:/tmp/cmnt:ro)
handle=$(gaol create -m /bin:/tmp/cmnt:ro)
assert_success

run gaol run -a -c "/bin/sh -c 'cat /proc/self/mounts | grep /tmp/cmnt'" $handle
Expand All @@ -45,7 +45,7 @@ load test_helper


@test "a created container can have explicit read-write bind mounts" {
handle=$(gaol create -m .:/tmp/cmnt:rw)
handle=$(gaol create -m /bin:/tmp/cmnt:rw)
assert_success

run gaol run -a -c "/bin/sh -c 'cat /proc/self/mounts | grep /tmp/cmnt'" $handle
Expand Down