Multiple-OS Header Access

Adam D. Ruppe destructionator at gmail.com
Wed Feb 12 09:48:10 PST 2014


version(linux)
void EnumProcessesLinux(void delegate(long) forEach) {
         import std.file;
         import std.algorithm;
         import std.ascii;
         import std.conv;
         foreach(string name; dirEntries("/proc/", 
SpanMode.shallow)) {
                 name = name["/proc/".length .. $];
                 if(all!isDigit(name))
                         forEach(to!long(name));
         }
}

void main() {
         import std.stdio;
         EnumProcessesLinux((n) => writeln(n));
}


Not the same signature as the Windows function (the windows one 
is weird imo) but the same functionality - this will print the 
process ID of everything on the system.


More information about the Digitalmars-d-learn mailing list