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

Allow return status to be specified using quitWithStatus #788

Merged
merged 1 commit into from Oct 23, 2014

Conversation

Projects
None yet
2 participants
@crabmusket
Contributor

crabmusket commented Sep 21, 2014

Call quitWithStatus(1), for example, to exit the program with a 1 status code. This is useful for unit tests and servers. Currently not implemented for Mac platform. Note that I haven't tested the Linux build yet because of VM issues, so I may rebase this at some point so it actually works on Ubuntu dedicated.

EDIT: The reason this is a separate command is because of this:

GlobalActionMap.bind(keyboard, escape, quit);

This will call quit(1) when the escape key is pressed because of the way TorqueScript works (AFAICT). Therefore to prevent incorrect default arguments from being passed, quit will always use code 0 and quitWithStatus will take an explicit code. quitWithErrorMessage has also been extended to optionally take a code.

@dottools

This comment has been minimized.

Show comment
Hide comment
@dottools

dottools Sep 21, 2014

I find it odd that you're storing return status as U32 when it'll be S32 from TorqueScript and then in main() are casting it to (int). Why not just store and pass it along as S32 to avoid confusion? Note that most common return error status codes are negative, not positive values.

dottools commented Sep 21, 2014

I find it odd that you're storing return status as U32 when it'll be S32 from TorqueScript and then in main() are casting it to (int). Why not just store and pass it along as S32 to avoid confusion? Note that most common return error status codes are negative, not positive values.

@crabmusket

This comment has been minimized.

Show comment
Hide comment
@crabmusket

crabmusket Sep 21, 2014

Contributor

Oh. Really? Ok, I'll make it an S32, that makes sense. Actually, would it not be more correct to just make it an int, since it may change size on 64-bit platforms?

Contributor

crabmusket commented Sep 21, 2014

Oh. Really? Ok, I'll make it an S32, that makes sense. Actually, would it not be more correct to just make it an int, since it may change size on 64-bit platforms?

@dottools

This comment has been minimized.

Show comment
Hide comment
@dottools

dottools Sep 21, 2014

Easiest way would be to use ssize_t to make it match native integer size. int goes up to 32bits and stops there. long is 64bit on 64bit builds, else 32bit. Now would have to check return code size on Windows, Linux, and Mac to determine if they do change on each OS depending whether x86/x86_32 or x64/x86_64/AMD64.

dottools commented Sep 21, 2014

Easiest way would be to use ssize_t to make it match native integer size. int goes up to 32bits and stops there. long is 64bit on 64bit builds, else 32bit. Now would have to check return code size on Windows, Linux, and Mac to determine if they do change on each OS depending whether x86/x86_32 or x64/x86_64/AMD64.

@crabmusket

This comment has been minimized.

Show comment
Hide comment
@crabmusket

crabmusket Sep 21, 2014

Contributor

I see. My thinking was that main has to return int, so the return code should be stored as an int, right? Let's at least pretend we have type-safety :P.

Contributor

crabmusket commented Sep 21, 2014

I see. My thinking was that main has to return int, so the return code should be stored as an int, right? Let's at least pretend we have type-safety :P.

@crabmusket

This comment has been minimized.

Show comment
Hide comment
@crabmusket

crabmusket Sep 22, 2014

Contributor

@dottools amended to use S32. Testing on Linux is about to commence...

...and once a deliberate segfault was removed, seems to work fine.

Contributor

crabmusket commented Sep 22, 2014

@dottools amended to use S32. Testing on Linux is about to commence...

...and once a deliberate segfault was removed, seems to work fine.

@crabmusket crabmusket added this to the 3.7 milestone Oct 11, 2014

crabmusket added a commit that referenced this pull request Oct 23, 2014

Merge pull request #788 from eightyeight/return-status-code
Allow return status to be specified using quitWithStatus

@crabmusket crabmusket merged commit 2f41629 into GarageGames:development Oct 23, 2014

1 check passed

default Merged build finished.
Details

@crabmusket crabmusket deleted the crabmusket:return-status-code branch Oct 23, 2014

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