Skip to content

FileHandle crash if you run multiple shellout calls#41

Description

@f-meloni

Hi 馃憢
I am developing this tool https://github.com/f-meloni/Rocket, and i'm using ShellOut for some of the available steps.
I would like to redirect the output of each step on the standard output, but if i do it this is what happens.

ShellOut method call:

func launchScript(withContent content: String) throws {
        try shellOut(to: ["export VERSION=\(version)", content], outputHandle: FileHandle.standardOutput)
}

Example steps:

steps:
  - script:
      content: echo "releasing $VERSION"
  - script:
      content: echo "releasing $VERSION"

Now if i run it with for example with version 0.3.0
This is what happens:

releasing 0.3.0
2018-12-05 08:10:03.537 Rocket[6079:92461] *** Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[_NSStdIOFileHandle writeData:]: unknown error'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff36a9ae65 __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff62af6720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff36a9ac97 +[NSException raise:format:] + 201
	3   Foundation                          0x00007fff38d701f2 -[NSConcreteFileHandle writeData:] + 74
	4   Rocket                              0x0000000103f484fc $SSo6NSTaskC8ShellOutE10launchBash33_839723A297212BDF262C1834C3E29C1FLL4with12outputHandle05errorN0S2S_So06NSFileN0CSgAKtKFyAJcfU_yycfU_ + 332
	5   Rocket                              0x0000000103f49a05 $SSo6NSTaskC8ShellOutE10launchBash33_839723A297212BDF262C1834C3E29C1FLL4with12outputHandle05errorN0S2S_So06NSFileN0CSgAKtKFyAJcfU_yycfU_TA + 21
	6   Rocket                              0x0000000103f4855d $SIeg_IeyB_TR + 45
	7   libdispatch.dylib                   0x00007fff63b75d53 _dispatch_call_block_and_release + 12
	8   libdispatch.dylib                   0x00007fff63b76dcf _dispatch_client_callout + 8
	9   libdispatch.dylib                   0x00007fff63b7d124 _dispatch_lane_serial_drain + 618
	10  libdispatch.dylib                   0x00007fff63b7dbdc _dispatch_lane_invoke + 388
	11  libdispatch.dylib                   0x00007fff63b86090 _dispatch_workloop_worker_thread + 603
	12  libsystem_pthread.dylib             0x00007fff63db663c _pthread_wqthread + 409
	13  libsystem_pthread.dylib             0x00007fff63db6435 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    6079 abort      ./.build/x86_64-apple-macosx10.10/debug/Rocket 0.3.0

The problem is the standard file handle close call solved on #23 (i tried this and it solves the problem work)

Is there any known workaround that i can use to redirect the output on the stdoutput in the meantime while that PR or maybe #32 gets reviewed an (if they are ok) merged? :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions