Skip to content

Add type restrictions to process #16065

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

Open
wants to merge 1 commit 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
6 changes: 3 additions & 3 deletions src/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Process
# not run any handlers registered with `at_exit`, use `::exit` for that.
#
# *status* is the exit status of the current process.
def self.exit(status = 0) : NoReturn
def self.exit(status : Int32 = 0) : NoReturn
Crystal::System::Process.exit(status)
end

Expand Down Expand Up @@ -285,7 +285,7 @@ class Process
fork_error.close unless fork_error.in?(error, STDERR)
end

def finalize
def finalize : Nil
@process_info.release
end

Expand Down Expand Up @@ -515,7 +515,7 @@ end
# ```
#
# See [`Command` literals](https://crystal-lang.org/reference/syntax_and_semantics/literals/command.html) in the language reference.
def `(command) : String
def `(command : String) : String
process = Process.new(command, shell: true, input: Process::Redirect::Inherit, output: Process::Redirect::Pipe, error: Process::Redirect::Inherit)
output = process.output.gets_to_end
status = process.wait
Expand Down
6 changes: 3 additions & 3 deletions src/process/status.cr
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ enum Process::ExitReason
# Returns `true` if the process exited abnormally.
#
# This includes all values except `Normal`.
def abnormal?
def abnormal? : Bool
!normal?
end

Expand All @@ -107,7 +107,7 @@ enum Process::ExitReason
# ```
#
# `Status#description` provides more detail for a specific process status.
def description
def description : String
case self
in .normal?
"Process exited normally"
Expand Down Expand Up @@ -413,7 +413,7 @@ class Process::Status
# ```
#
# `ExitReason#description` provides the specific messages for non-signal exits.
def description
def description : String
if exit_reason.signal? && (signal = exit_signal?)
"Process received and didn't handle signal #{signal}"
else
Expand Down