FLTK logo

Re: [fltk.general] Is FLTK (Linux, 1.5.0) usable in batch mode (without display)?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
[  All Forums  |  Back to fltk.general  ]
 
[ Previous Message ] [ New Message | Reply ] [ Next Message ]

Re: Is FLTK (Linux, 1.5.0) usable in batch mode (without display)? "'Albrecht Schlosser' via fltk.general" 13:57 Sep 29  
 
On 9/29/26 14:25 Basile Starynkevitch wrote:
Is it possible to code some open source FLTK software which can (like GNU emacs with its --nw option) be used in batch mode (without screen, keyboard, mouse).

Yes, see fluid. If used with fluid -c (or some other commands), it doesn't open a display.

An interesting example might be for instance to improve the CubeView example so that with the --show-pid-in-batch program option it would just output a message showing its pid (using getpid()) and would still work on Linux computer when started using the batch utility (or crontab).

The following program (taken from test/hello.cxx and modified) displays its PID without having a display:

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <unistd.h>
int main(int argc, char **argv) {
Fl_Window *window = new Fl_Window(340, 180);
Fl_Box *box = new Fl_Box(20, 40, 300, 100, "Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD + FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
// window->show(argc, argv); // must not show a window !
auto pid = getpid();
fprintf(stderr, "PID = %d\n", pid);
return Fl::run();
}
You can test it, for instance, like this:

$ unset DISPLAY
$ WAYLAND_DISPLAY=NONE
$ ./get_pid
PID = 182885

Your code must determine whether it's run in batch mode and must not open the display. There are a lot of things that would open the display, for instance any drawing calls, some font handling stuff, and - obviously - showing a window.

Note that I left everything except showing the window in the demo code above to demonstrate that a lot of stuff "works" w/o a display.

There is no switch that would just not open the display and skip anything that would be done *if* the display was opened.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/ae3624b9-bfae-4199-89ac-906edf5a9093%40aljus.de.
[ Direct Link to Message ]
 
     
[ Previous Message ] [ New Message | Reply ] [ Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.