|
Post by vovchik on Aug 13, 2014 9:25:44 GMT 1
Dear micko, I updated the source and binary to do what you suggested. I also noticed VERY slow internet last night, about the time you posted, but had no idea why. With kind regards, vovchik
|
|
|
Post by vovchik on Aug 13, 2014 14:53:35 GMT 1
Dear all, I just posted a slightly enhanced version that has an alighment flag (-a 0,1 or 2), which allows the text to be positioned left (default), centered or right aligned. with kind regards, vovchik
|
|
|
Post by barryk on Aug 21, 2022 11:22:08 GMT 1
Hi guys, Returning to this after a very long time! I still use the original popup that I attached in the first post of this thread, in EasyOS. I find it to be very handy and use it in a lot of scripts. I never got around to incorporating some suggestions in this thread, such as svg background, but did make some small changes in 2015 and 2017. The latest popup.bac is attached. The code has two USEC sections, and what I would like to do is convert those to 100% BaCon. I think that you guys could do that in 5 minutes with your eyes closed. Whereas, I am unclear how to BaConize it. Changing the subject, regarding HUG. It requires absolute coordinates, relative to the window. But, I'm wondering if it is technically too difficult to introduce coordinates relative to another widget. I know that the new GUI framework uses widget packing, which is great. Changing the subject back again... I have a very vague recollection that Peter did post BaCon code to replace that USEC daemonize code in popup.bac, but cannot find that, so maybe the recollection is wrong. popup.bac.gz (6.56 KB)
|
|
|
Post by barryk on Aug 21, 2022 11:46:36 GMT 1
To daemonize the program, would it be possible to use FORK? Like this:
pid = FORK IF pid > 0 THEN END ENDIF
So the parent would terminate and the child would keep going? Or, is using it that way fundamentally wrong?
|
|
|
Post by Pjot on Aug 22, 2022 6:36:51 GMT 1
Hi Barry, Yes, you could use FORK() for this, it is the same 'fork' you're using in your code. You probably may need to do something with the SIGCHLD signal in case the parent exits prematurely. For the 'struct' later on you could use the RECORD keyword for that to setup a type and then declare the variable as that type. Best regards Peter
|
|
|
Post by barryk on Aug 22, 2022 9:50:47 GMT 1
Yes, that is what happens, the parent exits immediately:
USEC pid_t pid,sid; // Fork off the parent process pid = fork(); // An error occurred if (pid < 0) exit(EXIT_FAILURE); // Success: Let the parent terminate if (pid > 0) exit(EXIT_SUCCESS); // On success: The child process becomes session leader if (sid=setsid() < 0) exit(EXIT_FAILURE); // Change the file mode mask umask(0); // Close out the standard file descriptors (unusable in daemon) //close(STDIN_FILENO); //close(STDOUT_FILENO); //close(STDERR_FILENO); //open("/dev/null",O_RDONLY); //open("/dev/null",O_WRONLY); //open("/dev/null",O_RDWR); close(STDIN_FILENO); if (open("/dev/null",O_RDONLY) == -1) exit(EXIT_FAILURE); int logfile_fileno = open("/tmp/popup_log",O_RDWR|O_CREAT|O_APPEND,S_IRUSR|S_IWUSR|S_IRGRP); if (logfile_fileno == -1) exit(EXIT_FAILURE); dup2(logfile_fileno,STDOUT_FILENO); dup2(logfile_fileno,STDERR_FILENO); close(logfile_fileno); END USEC
Exit is at this line "if (pid > 0) exit(EXIT_SUCCESS);" And in doing so, it doesn't kill the child.
The child then continues and calls this:
// On success: The child process becomes session leader if (sid=setsid() < 0) exit(EXIT_FAILURE);
But I cannot see an equivalent to setsid() at the BaCon level, so it seems that I still have to use USEC.
|
|