pradosoft / prado

Prado - Component Framework for PHP
Other
187 stars 70 forks source link

isSystemWindows function to check for windows #938

Closed belisoful closed 1 year ago

belisoful commented 1 year ago

There should be a common function for checking for windows.

@ctrlaltca can you suggest what the best path might be?

Use Case: There are some properties of proc_open (aka priority and changing process priority) that is system dependent on shell commands.

Proc_Open is going to be using endian from TDataStream to enable binary data writing to pipes, so TBitHelper kind of does makes some sense from that perspective.

ctrlaltca commented 1 year ago

If it's only going to be used by a method to determine proc_open()'s options, i'd keep it near to the caller method (inside the same class)

belisoful commented 1 year ago

it's three methods for getting and setting the priority of a proc_open from the parent. It's easy enough to set from the child , there is proc_nice for that. But to set from the parent it requires a touch of shell_exec wizardry that is system dependent. linux is simple enough, ps to get nice priority and renice to set it. but windows isn't so simple.

Given that it is kind of a systemic thing for people, I thought it would be nice to provide a function for that. Kind of like determining the system endian is a systemic issue that is easily resolved so it's not reinventing the wheel each time.

Edit: three methods, also one for getting the current process priority without pcntl. I realize pcntl is possible, but I'm thinking if it isn't installed or doesn't work (like on windows).