% -*- mode: slang; mode: fold; -*- implements ("tsca_func"); % ----------------------------------------------------------------------- %{{{ "tsca_func->countem(x)" will give you the number of currently running % instances of slrn. % x = 0 --> in general on your system % x = 1 --> owned by you ($USER) % % The function requires `ps` and `grep` in your system % and due to the use of popen() won't work in Windows. % %}}} Thu, 21 Mar 2002, tsca@edb.dk define countem (tfu) { variable ins, fpp, ps_query; if (tfu) ps_query = "ps ho \"%u\" -C slrn|grep "+getenv("USER"); else ps_query = "ps h -C slrn"; fpp = popen(ps_query, "r"); if (fpp == NULL) return -1; ins = fgetslines (fpp); if (ins == NULL) return -1; ()=pclose(fpp); return length (ins); } % - end -------------------------------------------------------------------