I’d like to see the unit tests for the non-true return state.
It's actually pretty straightforward: turn_computer_off(); Assert(!is_computer_on(), "Computer should have been off but it's on."); The opposite is a bit tricky, though.
How to programmatically find out if computer is on
61–70 of 197 posts
Re: How to programmatically find out if computer is on
#62Re: How to programmatically find out if computer is on
#63I’d like to see the unit tests for the non-true return state.
Re: How to programmatically find out if computer is on
#64Re: How to programmatically find out if computer is on
#65Earlier quoted context omitted.
Hmm, it seems like you need to make sure the computer is on before calling this function, or else you run the risk of getting back undefined data. Seems like we also need a function that can be used to tell if the computer is on...
There's a syscall to check whether the computer is on so just call that before this and you'll be fine
Re: How to programmatically find out if computer is on
#66Re: How to programmatically find out if computer is on
#67Where does the code run when the computer is off? Edit: I see the downvotes, yet i still don't know if it's a joke. I was genuinely asking the question.
Genuine answer: the code cant run when the computer is off, thus the joke. The question is worth asking (all are) but then soliciting "quantum computing" as an answer makes it a doubly worthy set up line, so thanks twice.
Re: How to programmatically find out if computer is on
#68Re: How to programmatically find out if computer is on
#69> If the computer isn't on, the value returned by this function is undefined. Shouldn't it just block until the computer turns back on? Probably interferes with pthreads.
Seems like a reasonable compiler would inline the most likely implementation as 1. So, while technically undefined, it's safe to assume that it will 'return' 1 regardless of the actual on/off state of the computer.
Re: How to programmatically find out if computer is on
#70How does this relate to computer being in Halt state, which is quite valid state for servers (there could be even a dedicated Halt button)? Technically computer hardware is ON. I remember that in such state it shows a "carrot" prompt (>>>) from the SRE console.
By the way, there is also HCF instruction (Halt and Catch Fire).
https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing...