[PD] pd command-line options . ( -guicmd , -guiport )

Martin Peach martin.peach at sympatico.ca
Mon Aug 6 23:42:37 CEST 2007

errordeveloper wrote:
> hello pd-list.
> I would like to find out more on how exactly the undocumented options
> '-guicmd' and '-guiport'  might be used?
> when pd starts up it usualy listens to port 5401 and the netstat gives 
> %netstat|grep 5401
> tcp        0      0 localhost:5401          localhost:52381
> tcp        0      0 localhost:52381         localhost:5401
> does it mean that 5401 if where 'pd' sits and 5381 is where  'pdgui'
> comes from?  so the could be on different host or there any
> restrictions? i have got pd compiled only one machine , so could not
> test this yet ..
 From my notes that are a few years old now, this is how pd starts up 
the gui interface:
     sys_startgui(sys_guidir->s_name): in s_inter.c sets up some signal 
handlers, opens a TCP socket (sys_guisock)
                       on port 5400 (FIRSTPORTNUM) and then forks.
                       The child starts the gui process:
                       Under unix, the environment variables TCL_LIBRARY 
and TX_LIBRARY are declared
                       and the pd-gui program is called with the port 
number as argument:
                       /bin/sh sh -c 
"GUIDIRPATH/pd-gui" 5400
                       where LIBDIRPATH = sys_libdir->s_name, usually 
/lib/pd, and GUIDIRPATH = guidir, usually /lib/pd/bin
                       On Windows and MacOSX, the Wish shell is spawned 
and fed the pd.tk script.
                       The child doesn't return.
                       The parent thread sets a higher priority, then 
forks again to start a watchdog process.
                       Finally the parent thread calls
                           socketreceiver_new(0, 0, 0, 0);
(t_fdpollfn)socketreceiver_read, sys_socketreceiver);
                           sys_vgui("pdtk_pd_startup {%s} %s\n", 
pd_version, buf): pdtk_pd_startup is in pd.tk. It calls pd
                           with the pd command and the argument init.
                           The class pd has glob_initfromgui() as the 
handler for the init message.

> also another option - '-guicmd'  - what about this one?
 From the help text:
"-guicmd \"cmd...\" -- start alternatve GUI program (e.g., remote via 
The relevant call is in sys_startgui in s_inter.c:
execl("/bin/sh", "sh", "-c", sys_guicmd, (char*)0);
..which defaults to calling Wish, the TCL shell.
This bit isn't used for MSW versions though. (Seems to be because 
Windows TCL doesn't have a callback mechanism so pd has to keep polling 
the gui.)

More information about the Pd-list mailing list