Asset - Extension Process Information (for Windows, macOS, and Ubuntu)

Samuel Venable

Time Killer

Execute external applications from the shell, with the possibility of reading their standard output file descriptor, as well as writing to their standard input file descriptor, and reading general information from processes running on your machine's current session, such as the current working directory, environment variables, command line arguments, executable path and filename, and more! You can even enumerate all processes running on your current user session allowing you to inspect these properties at ease and the possibilities are endless! Do a search for processes running with a particular filename, or search based on the parent directory executables are running from. Run your GameMaker Studio creations with Admin / Super User Privileges for even more power over what you can see is going on behind the scenes in your computer. Offers advanced functionality great creating your own headless servers, game launchers/app menus, run batch and other various shell script formats, etc...

Download Free for GameMaker Studio 2.3 (Marketplace)
Download Free for GameMaker Studio 2.3 (itch.io)

RPI BUILD ON GITHUB RELEASES
CLICK HERE FOR DOCUMENTATION
CLICK HERE TO SUBMIT A BUG REPORT
CLICK HERE TO CONTRIBUTE

Shell Executation and Evaluation (with Process Information) Tutorial:
 
Last edited:

Samuel Venable

Time Killer
lol I can't help but notice that this is basically just like my most popular asset on the marketplace, Execute Shell, but on steroids. Execute Shell has thousands of downloads, and a crap ton of 5/5 reviews. I wonder why this asset, which capable of all the same things, and a lot more than that, hasn't really gotten any traction yet? Does anyone actually know what this extension even does? Am I not describing it properly? Or am I just overthinking it with my impatience?
 

Samuel Venable

Time Killer
@Unknown Entity I fixed this extension if you ever happen to need it. It should no longer hang for you. If you are ok with updating and trying it again that would be great so other people will be able to see you verified it works now.
 

IGameArt

Member
This can be used to execute batch files? I'm having a tough time getting it to do what I'm trying. Essentially I'm saving a surface to a png then trying to use this to convert it to another format using a bat file with the proper instructions.

GML:
var dir = working_directory+"\Assets\\Dependencies\\ConvertStepA.bat";
dir = @'"'+dir+@'"';
show_message(dir);
process_execute(dir)
I've placed quotes around the directory but it doesn't launch the bat, even if I use get_open_filename to track down the file I want to launch manually it still fails to do anything.
 

Samuel Venable

Time Killer
var dir = working_directory+"\Assets\\Dependencies\\ConvertStepA.bat";
dir = "cmd /c " + @'"'+dir+@'"';
show_message(dir);
process_execute(dir)

Should do the trick. :)
 

IGameArt

Member
I'll give that a shot when I get home, thanks!

EDIT: Still getting no results. It's like it can't find the file or something.
 
Last edited:

Samuel Venable

Time Killer
Is anyone else able to reproduce this problem with batch files not working, even when attempted the way I mentioned? I'm still waiting to hear back from @IGameArt with a private conversation we're having regarding the issue, and if I could debug it and find the source of the problem sooner, it would help him and potenially others.

Edit:

Just noticed a problem with the code provided.
var dir = working_directory+"\Assets\\Dependencies\\ConvertStepA.bat";
dir = @'"'+dir+@'"';
show_message(dir);
process_execute(dir)
There is an unnecessary backslash that bwoke it. It should be:

var dir = working_directory+"Assets\\Dependencies\\ConvertStepA.bat";
dir = @'"'+dir+@'"';
show_message(dir);
process_execute(dir)
 
Last edited:

Samuel Venable

Time Killer
New function available!
GML:
string cwd_from_pid(process_t pid);
Allows the developer to get the working directory of external running applications based on their associated process id. This was a pain in the neck to add.
 

Samuel Venable

Time Killer
GMS2 - Version 0.9.8. Published August 4, 2020


WARNING: this update has important API changes which will break existing projects! Please update your projects to adapt to these changes:

  • Some functions have a new "process index" argument added to allow getting the output, and process id's, from multiple processes, that have been executed, and that are running simultaneously. The "process index" argument is labeled "ind" in the GML code editor's intellisense. For this argument you must specify a number of your choosing to uniquely identify processes created with process_execute(ind, command) and process_execute_async(ind, command).

  • To delete the recorded output and process id of the given process index, use the functions process_clear_out(ind) and process_clear_pid(ind). This will also free those elements from memory, so do not forget to call these functions whenever you are done getting the output and process id of a given process index. If you are not getting either of those things, be sure to free memory with these functions regardless, and in which case, it would be best to do so for every process index used in all calls to process_execute(ind, command), and process_execute_async(ind, command), immediately after executing each process individually.

  • it is recommended that if you need to know which process index has which process id number or output string, you store the value of the process index in a variable name that easily identifies the executable or command that is associated with each individual process index.
 
Last edited:

Samuel Venable

Time Killer
Hey guys, after a lot of putting off, I'm finally writing some decent documentation for this, diving right in to everything this extension can do and explaining it in depth function-to-function. Here's what I have so far, which covers everything you need to know on how to execute processes and read their output, both synchronously & asynchronously: https://www.dropbox.com/s/ahbhcsum51he7nb/docs.html?dl=0

Up next I will cover how to retrieve a lot of various information from both the processes you execute, as well as external running processes.

Please let me know if it makes sense at all, I hope it does! lol
 

Samuel Venable

Time Killer
Added a new function explained in the discord screenshot below. Currently this update is only available on itch.io but I'll be adding it to the marketplace soon.

 

EvanSki

Raccoon Jam Host
Thank you! I assume my documentation and code examples made sense, otherwise you would've had some questions for me! haha
Yeah I got the hang of it, I would put the information here such as the discord stuff and you 0.9 update info in the docs.html then have the html stated on the itchio page, but I found them and there easy to understand through practice so it all works out
 

Koyan

Member
lol I can't help but notice that this is basically just like my most popular asset on the marketplace, Execute Shell, but on steroids. Execute Shell has thousands of downloads, and a crap ton of 5/5 reviews. I wonder why this asset, which capable of all the same things, and a lot more than that, hasn't really gotten any traction yet? Does anyone actually know what this extension even does? Am I not describing it properly? Or am I just overthinking it with my impatience?
Yes this and all of the other extension's you've build are AMAZING dude... but probably you gotta work on your 'titles' a bit more. Because even tho icon's are the same, first i thought it was a completely different object with new and other functionalitys.
 

Samuel Venable

Time Killer
I won't be publishing the next update until I have have access to a mac again (sold my old one and bought a new one, just waiting for an adapter to come in the mail so i can hook it up to my monitors) anyways in the meantime I have released this extension for the raspberry pi. Replace the libprocinfo.so in your existing projects while backing up the original file so you may swap the old/new file between each other depending on whether you intend to target the pi with your builds. Download it here: https://github.com/time-killer-games/libprocinfo/releases/tag/v1.0.0.0
Yes this and all of the other extension's you've build are AMAZING dude... but probably you gotta work on your 'titles' a bit more. Because even tho icon's are the same, first i thought it was a completely different object with new and other functionalitys.
Also to address what you said, the titles are just fine, they make it easier to understand what exactly the extension does if I make it as obvious as possible with a generic name and no bs username/fake-company-name branding like most other users seem to think is good, I don't. The icons i agree though need brushing up on, I just have bigger priorities at this time, and your last thing you said I don't honestly understand what you mean, all of my extensions are completely different in what they offer, some more than others, but I certainly do not share duplicate assets.
 
Last edited:

Samuel Venable

Time Killer
Ok so added huge performance increases for the following functions on Windows, and I will also review what they do:

cwd_from_pid(pid) - returns the current working directory of an external application based on its process id (or pid). On Windows this will usually (always?) include a trailing backslash. On Unix-likes such as Mac and Linux, no trailing forward slashes are present.

cmd_from_pid(pid) - returns the full list of command line arguments, in a single string, which were passed to an external running application, when it was first executed, based on the given process id, (or pid). This string can be modified by the application at runtime and therefore it is an unreliable source of information, unless you are the author of the target exe and know it is not modified at all.

env_from_pid(pid) - returns the entire process environment block, (or PEB), of an external running application based on its process id, (or pid). This is the full list of environment variables associated with that application in their current state, and their values can be modified at runtime, so it can be useful for things such as inter-process communication, (or IPC), though slower compared to other forms of IPC, such as unix sockets and various networking techniques. Parsing the string is required for general use outside of debugging purposes.

env_from_pid_ext(pid, name) - returns the environment variable value, from the given name, associated with the external running application, whose process id is equal to pid. The value is not surrounded in double quotes and no extra escaping of double quotes or backslashes are added, unlike the values returned from env_from_pid(), which does this to allow for more accuracy with values when string parsing. Because no parsing needs to be done in env_from_pid_ext(), the returned value is not modified and it will equal the exact value of the environment variable name provided.

Also, due to a regression, env_from_pid() used to crash whenever called on Windows, this was because I was using a reserved variable name, specifically, "environ" which shouldn't be used at all outside of getting the current application's environment block, I ended up fixing that crash by using a different variable name.

Lastly, I also fixed a crash on macOS with env_from_pid() that would occur on certain circumstances, and it was because I was not properly initiallizing a pointer as nullptr before attempting to conditionally change its value and check thereafter whether it still equaled nullptr.
 
Last edited:
Top