Every SD session is a process with a user number, and almost everything on
this page takes one. The number is not the Windows process id and it is not the
account name: it is SD's own handle on a session, it is reused after a session
ends, and it is what pstat and pdump both expect.
A phantom is a session with no terminal. You start one, it runs a command in the background under its own user number, and what it would have displayed is written to a file instead.
SD folds case, so a command may be typed in either case. Commands are shown here in lower case. In the tables, italics mark something you supply and bold marks a word typed as it stands; braces mark an optional part.
What is not on this page#
Seeing other people's sessions, and ending them, are administrator verbs.
listu lists every session on the machine and logout n ends one, and
neither is in an ordinary account's VOC. They are documented in the
administrator documentation, under Sessions and Locks, which is a
separate set your administrator may or may not have given you.
logout with no argument is the exception and every account has it — it
ends your own session and is quit under another name. That is worth knowing
before typing it intending to list something.
What is here is your own processes: what this session is doing, work you started in the background, and how to look at either.
What a session is doing: pstat#
pstat {user n} {level n} {no.page} {lptr {n}}
With no arguments it reports every session; user n restricts it to one.
:pstat
User Detail
27 Account: DON
Command: pstat
$PSTAT 141 (262)
12 (Not responding)
Each line under a user number is the account it is in, the command it is running, and where in that command it currently is — program name, source line, and the address in hexadecimal.
For a process that is waiting for a lock, pstat also shows when the wait
began, as list.readu detail already did.
What pstat prints is another session's text, and it is made safe first.
The command, the record it waits for, its program names and its account are shown with each control
character, del, byte from 128 to 159 and mark character as ?, so that a session cannot send a code to
your terminal by what it types or locks. The text of @pstat (below) gets the same treatment, except that
its marks are still shown as spaces.
The levels are additive#
| default | the current program only |
level 1 |
the whole call stack |
level 2 |
the internal subroutine stack — where each gosub will return to |
level 3 |
both |
From inside a running program, which is where the levels are worth having —
at the prompt there is nothing on the stack but pstat itself:
User Detail
27 Account: DON
Command: pstat user 27 level 1
$PSTAT 141 (262)
Command processor
/cygdrive/c/ProgramData/SD/user_accounts/don/BP.OUT/ZZMATH 34 (152)
Command processor
Read it downwards: $PSTAT is running, called by the command processor, which
was reached by execute from the program ZZMATH at line 34, which the command
processor started. level 3 adds an indented line under each frame for the
gosub inside it.
(Not responding) means the process is gone, not busy#
pstat does not read another session's memory. It asks — it posts an event
to the target and waits for the answer, for up to four seconds. A session that
never answers gets that line.
That is the cheapest way to find a dead session. A session killed from
outside SD keeps its entry in the user table and its slot is still counted;
pstat is what tells you nothing is behind the entry. User 12 in both listings
above is one of those. Clearing it is an administrator's job — reporting the
user number is the useful thing you can do.
Running something in the background: phantom#
phantom command
The command is everything after the verb. SD creates a new process, gives it a user number, and answers at once:
Started phantom user 31
Your session does not wait, and the phantom has no terminal, so anything it
would have displayed goes to a como record instead — in the account's
$COMO file, named PHn_ddmmyy_hhmmss for the phantom's user number
and start time. $COMO is created if the account has not got one. The first
line in the record is the phantom's own banner:
Phantom 31 started at 14:22:07 27 Aug 2026
so a phantom that produced nothing else is still distinguishable from one that never started.
| refusal | when |
|---|---|
| Phantom command missing | phantom with nothing after it |
| Phantom processes cannot be started within a transaction | inside begin transaction |
| Failed to create phantom process | the operating system would not create the process |
A phantom that is created and then cannot run SD's program ends without a word on your
terminal, and phantom returns as it always did. The reason is written to SD's error
log, for the administrator to read, as a line beginning phantom: cannot start a phantom
from and the path of sd, then the reason; a path too long to start from is a line
beginning phantom: cannot start a phantom - the path of.
A phantom cannot be started from a scripted session, and this is the one to know. When SD is fed commands down a pipe, the phantom child inherits that pipe. The job then never completes — not even after the parent session has exited — and the only way out is to kill the process, which leaves an entry in the user table that needs an elevated
sd -cleanupto clear.phantomis for a person at a prompt, or for a program, and not for a piped script.
A phantom is not a scheduled job. It runs once, now. Recurring work is a Windows scheduled task that starts SD, and that is a different subject, covered under Scheduled jobs in the Getting Started set.
A phantom that ends with its parent: phantom group#
phantom group command
A phantom started with the word group is grouped with the process that started it:
when that process ends — it logs out, or is logged out — SD logs the grouped phantoms
out too, where an ordinary phantom would go on until its command finished. It is for a helper that has no purpose without you. listu shows a
grouped phantom with a G after its parent's number, and system(1073) in the
parent gives the user numbers of the phantoms grouped with it, field mark delimited
(system(1058) gives all its child phantoms, grouped or not, and system(1052) counts
them). A phantom that has not yet finished starting when its parent ends is still
logged out.
A phantom with a user number of its own: phantom user#
phantom user n command
The phantom is user number n. The numbers are the ones the administrator keeps for this
with the PHANTOMS parameter of sd.conf (PHANTOMS=900,4 keeps 900 to 903); no session and no
phantom started without user is ever given one of them. It is for a service that other
programs find by its user number. user may stand beside no.msg, data, group and log, in
any order, and phantom returns the number as it always does.
| refusal | when |
|---|---|
| phantom user needs a user number | user with nothing after it, or something that is not a whole number above 0 |
| user number n is not one of the numbers the phantoms parameter keeps | n is outside PHANTOMS, or the administrator has set none |
| user number n is already in use | a phantom (or anybody) has it now; no phantom is made |
With USPLIT=1 the numbers are not kept from other processes, but user n still takes a free one.
@pstat: what pstat shows about the program#
@pstat is an @ variable a program may assign to. Whatever text it holds when
another session runs pstat (or pstat user n) is printed as an extra line under the
process's last command and location, so a long-running program or a phantom can say what
it is doing — @pstat = 'Posting batch ' : n — without a terminal to say it on. It is the
program's own text and is not cleared for it.
What a phantom does not inherit#
A phantom is a new SD process, not a branch of yours. It is started with
fork and exec and goes through login of its own, so nothing your session
holds in memory reaches it — no @-variables, no unnamed common, no open
files, no active select list. The command string is the only thing passed,
through a record in SD's $IPC file. The session's option settings do not go
with it: a phantom starts with every option off. (There is no option inherit.)
The records are sealed. $IPC is a file every SD user's process can write, so a
phantom does not believe what it finds there. phantom makes a secret for each
phantom (24 random bytes) before it creates anything, gives it to the new process in
its environment (SD_PHANTOM_NONCE, which only the same Windows user can read; the
process copies it as it starts and overwrites the string where it stood, so nothing the
phantom runs inherits it), and puts an HMAC-SHA256 seal over the
command, the DATA queue and the log file name in the record. The new process makes
the seal again from what it read and runs, stacks and sets nothing unless the two
are the same. A phantom whose records do not check ends at once, says so in its
como log and to its parent (Phantom n : start-up records missing or not from the
process that started it, nothing was run), and writes a phantom refused line to
the audit trail. If the secret cannot be made, no process is started.
What phantoms have I started: status#
status
:status
There are no phantom processes started by this process
which is the answer in any session that has not started one. When there are some, it prints a user number, the start time and the command for each:
User Started Command
It reports only your own children. It is not a system-wide view and it is
not listu — a phantom somebody else started does not appear, and neither does
one your session started before you logto'd somewhere else. The register it
reads is keyed by the parent's user number.
Every phantom that is running: list.phantoms#
list.phantoms
list.phantoms user name
Lists the phantoms, and no other session: a header, then a line for each
with its user number, its operating system process id, the login name it runs
as, the time it started and the account it is in (the phantom starts in its
parent's account). user name shows only that user's (the name is case
sensitive). The account is shown for the administrator and for your own
phantoms, and left blank for anyone else's, as listu does. openQM's
pool word is refused (SD has no pools of phantom processes), and user
without a name is User name required after USER.
User Pid Username Login time Account
26 5124 sduser 21 Oct 00:11 sduser
A phantom is listed only once it has signed on: phantom reports the user number it has given the new
process at once, and a list.phantoms typed in the same second may show the heading and nothing under it.
Telling a phantom what to do: child() and signal()#
child(userno)
signal(userno)
system(1062)
child(userno) is true if userno is a phantom this process started and
it is still running; the number is the one phantom hands back. Any other
number, and a phantom that has ended, give false.
signal(userno) raises a flag in the process with that user number and is true
if that process is logged in; the other process reads and clears it with
system(1062). It is the simple way to ask a phantom to stop:
loop
... the work ...
until system(1062)
nap 100
repeat
SD signals only a process of the same login user (the administrator can signal any): to a process of another user it gives false and does nothing. Two signals before the other process reads one are one signal.
Dumping a process: pdump#
pdump n
Writes a snapshot of session n to a file and carries on; nothing is stopped
and nothing is lost. The file is sddump.n in the directory named by the
DUMPDIR configuration parameter. The shipped sd.conf sets it to
C:\ProgramData\SD\sdsys\dumps; if it is empty, the dump goes to SD's own system
directory instead:
Dumping process state as C:\ProgramData\SD\sdsys\dumps/sddump.27
It holds the @-variables, the current sentence and command, the call stack,
open files and their locks, and named and unnamed common — which is to say it
holds application data. The installer makes the dumps directory so that an
SD user can add a dump but cannot list the directory, and a dump is readable by
the user who wrote it, by SYSTEM and by the Administrators. Treat a dump as you
would the data of the program that produced it, and delete it when the question
it was written to answer has been answered.
| refusal | when |
|---|---|
| User number required | pdump with no number |
| Not logged in | no session has that user number |
| PDUMP not allowed for processes run under other usernames | the PDUMP configuration parameter has bit 1 set and the session is not elevated |
It is an event, not a call. pdump marks the target and returns; the target
writes the file when it next looks at its event flags. A process that is wedged
somewhere that never checks will not produce one.
Debugging a phantom: pdebug#
pdebug attach to a phantom that is waiting for a debugger
pdebug command start command as a phantom and attach to it
pdebug puts the SD debugger on this terminal and the program in a
phantom, which is the only way to debug something that has no terminal of
its own. With a command it starts the phantom for you; with none it waits for
one to ask for a debugger, and Q gives up waiting.
It refuses inside a phantom or an API session — Phantom debugger can only be executed from an interactive session — because it needs a terminal to draw the debugger on.
pdebug and the phantom leave each other their messages in a private store,
not in $IPC: a private folder of the Windows user who runs them, sd\pdebug in
the AppData\Local folder of that user's profile (found from the profile, never
from %LOCALAPPDATA%). SD makes the folders when they are missing, with access for
that user, SYSTEM and Administrators only, and uses the store only when no folder
on the way is a link and nobody else can add, delete or rename anything from the
profile down. So a pdebug and a phantom reach each other only when both run as
the same Windows user; pdebug waiting and a phantom started afterwards by the
same person works as before. When the store cannot be set up, pdebug says so and
stops (The debugger's private directory could not be set up (reason), so the
phantom debugger cannot start), and a phantom behaves as if no pdebug were
waiting. The store outlives a restart of SD, so pdebug removes the records of its
own user number when it starts, and a phantom ignores a start record whose
pdebug has gone.
Do not send
pdebugdown a pipe. It polls the keyboard while it waits, and in a piped session the input stream is the script, so it consumes the commands that have not run yet. Together with the phantom it starts, that is two ways for one verb to hang a scripted session.
The debugger itself — the commands it takes once it is attached — is in SD Basic - Debugging.
Where the work goes: profiler#
profiler on {user n} {event ...} start logging
profiler off {user n} stop logging and keep what was logged
profiler {display} {user n} show it
The kernel of the process being profiled counts its events: what it called,
what it opened, read, wrote and deleted, and what it executed. on starts the
count, off stops it and keeps the table, display (the default) shows it.
The events are call open read write delete openseq readseq
writeseq execute and object; none named means all of them. Without
user the verb profiles your own session.
profiler on read write
list t3 name
profiler off
Profiler on for user 28
...
Profiler off for user 28: 29 events in 13 entries
(The ... is the report list printed.) The table is kept in SD's $ipc file under the user number, so no file is
left on the disk. A profile outlives the session that made it: the profiles of sessions that have already
ended can still be listed.
profiler (or profiler display) then shows it. With several profiles it
lists them and asks which to open:
Profiles available (user number, events, entries):
25 24 9
28 29 13
User number to open, or Q to quit:?
With exactly one
profile it opens that one without asking, and profiler display user 28 names
one. There are four levels, and you go down by typing the number of a line and
up with b; q leaves:
Event types
1 29 READ
Line number to open, B to go back, Q to quit:?1
READ events, by name
1 4 (none)
2 14 T3
Line number to open, B to go back, Q to quit:?
| Level | Shows |
|---|---|
| 1 | the types of event, with a count of each |
| 2 | what the events of that type were on: a file, a subroutine, a command |
| 3 | the programs that did them |
| 4 | the lines of the program, with the count at each |
A program with no line table (an I-type) has none to show at level 4 (No line numbers were recorded for this program), and a profile that filled up says how many events it did not log. A profile that is not there is There is no profile for user 1 - use profiler on, run the programs, then profiler off. Another user's process can be profiled by the administrator only, because a profile holds the files that user's programs open and the commands they execute (Only the administrator can profile another user's process).
Who has these verbs#
Every account has status, phantom, pstat, pdebug, pdump,
list.phantoms and profiler —
there is no withheld set any more.
pdump still has a gate, and it is not about having the verb. pdump
n is yours to use on your own processes; against another Windows
account's process, it refuses unless the session is SDSYS's. pstat reports
any session, with no such restriction.
See also#
SD TCL - Locks · SD TCL - The Terminal and the Session · SD Basic - Debugging.