issues with fork() and taking a file as input standard - redirect

i have a program called tinydb this program use 4 fork() to create 4 child process called insert,delete,update,select .the parent process send message from the getline(cin,buffer) to the corresponding child by check the first word.the children process will execute the message and create a log file and cout the directory/name of the log file.
all are working when i send command to tinydb however when i try to use a file as a input standard for tinydb ,something is going wrong. ./tinydb student_db.bin < query.txt on the console all i see is the cout of the parent process ,the cout of the child process is not shown and the child doesnt create a log file however when i try to use debug on clion for tinydb with the rediction input of clion = query.txt all work fine.the cout of children are shown the logs are made.
i really want to know why its wrong, thank you.
p.s : i can't find the tag for redirection of the input standard to a file.
find a way for my children to be able to cout to the terminal and create a log.

Related

Eclipse deletes "problems/errors" as soon as I edit the file that had the error

I have a custom error Parser which detects some regex in the console output and highlights them as errors.
This works fine. However, lets say file1 has 20 errors, as soon as I edit and save file1, to fix one of the errors for example, the complete list of errors from file1 is deleted. And thus cannot navigate to them easily.
how can I disable that to have the errors/problem persist until the next build?

Is it possible to use GDK or GTK to pull user generated content from an active firefox window? (Similair to FIndWIndow on Windows)

I am working on a bit of a hobby project while trying to better understand the windowing system in Linux. I want to create a program that will constantly print the contents of the active textbox in a firefox window. I know this is possible on windows with FindWindow, but I am curious whether this could be duplicated on Linux.
I am currently running this on ubuntu, with the standard version of firefox. So far, I have been able to pull in a foreign window based on the window ID, but cannot seem to get past that. The current script simply prints out the display width of the firefox window.
uint xlib_window = 0x00800010; //firefox window id
gtk_init(&argc, &argv);
GdkDisplay * gdk_display = gdk_display_get_default();
GdkWindow * temp = gdk_x11_window_foreign_new_for_display(gdk_display, xlib_window);
cout << gdk_window_get_width(temp) << endl;
I would like to be able to find the current active widget, and print whatever it contains it is a text buffer. Right now, I am only able to find generic information about the window.

CMD, REXX, need a way to detect an error

I'm very very new to programming/coding.
And I have a very specific question, which I didn't find any answers to.
This command below executes perfectly fine if the command is valid.
If I enter an invalid command, an error occurs and the cmd exits.
enter image description here
But how do I make it, if an error happens, the program starts from the beginning rather than the cmd window closes?
So, in short, I want "SIGNAL start" to happen if an error occurs.
I hope you understand, thank you very much.
other:
SAY "Enter your own command:"
PULL command
command
IF command=ERROR THEN DO
SIGNAL start
It would be helpful if you published all of your code but it seems that what you really need to do is code a loop.
/* REXX */
do forever
say "Enter a command"
pull command
"where" word(command,1)
if rc <> 0 then iterate
command
end

Execution of an external program in MATLAB - succeeds only when using &(ampersand), but then does not wait for completion

I am attempting to execute an external program from Matlab:
cmdstr = sprintf('"%s\\myEXECUTABLE" "%s" -options',fullEXEpath, fullInputFilePath);
[status, res] = system(cmdstr);
I receive "status = 1", partial program output in "res" (though no error message) and no output files.
BUT, executing exactly the same command with & (ampersand):
cmdstr = sprintf('"%s\\myEXECUTABLE" "%s" -options &',fullEXEpath, fullInputFilePath);
[status, res] = system(cmdstr);
Meaning in the background via a dos command window, works just fine (status equals 0 and output files are created).
I have seen somewhere it might be that the antivirus is blocking the program from executing via Matlab, but I cannot disable it since I am an endpoint user.
Using "&" causes my GUI to open a command window and run in the background, while immediately resuming Matlab code.
I can live with the command window opening, but not with Matlab resuming right away, as I use the output files in my MATLAB code, which are not necessarily ready.
Is there a way to verify the external program has ended?
I tried simply:
while (status) %waiting for system to return status = 0
disp 'waiting...';
end
but it seems to still return with "status = 0" before completion...
Or rather - is there a way to avoid the &?
Any answer will be much appreciated.
as a debugging method, you can use
system(cmdstr,'-echo')
Since the error messages have nowhere to go, you wouldn't see them. (matlab only returns the output, which might not contain the error stream)
Am I correct you are calling a GUI program with that command? According to the matlab documentation:
The ampersand, &, character has special meaning. For console programs
this causes the console to open. Omitting this character causes
console programs to run iconically. For GUI programs, appending this
character causes the application to run in the background. MATLAB
continues processing.
So console programs (headless programs) would not allow Matlab to continue while executing.

Progress-4GL Writing to log file

When running a progress-4gl program, I am able to write to a log file using the log-manager. However, when writing out message statements they only appear when I use message view-as alert-box. ie:
log-manager:logfile-name = "queue.p"
message "this will not appear".
message "this will appear" view-as alert-box.
Will show up in the log file as:
[12/05/10#09:03:21.154-0700] P-11993170 T-000001 1 4GL -- this will appear
Is there any way I can force the log-manager to write out message statements that do not include view-as alert-box? Our legacy code uses the message statement everywhere and I would prefer to not have to go through all related libraries updating it.
I fear getting messages (without "VIEW-AS ALERT-BOX") to the clientlog file is not possible.
Progress help says: "OpenEdge writes all ABL VIEW-AS ALERT-BOX messages to the log file".
(LOG-ENTRY-TYPES attribute > 4GLMessages).
Are you thinking of something like the LOG-MANAGER:WRITE-MESSAGE( ) method?
you should use in this case a Batch startup parameter. -b
then will no messages displayed (except errors).
prowin32.exe -p c:\test.p -b
you can define, where should be the messages logged. then will not displayed the errors too.
for example:
prowin32.exe -p c:\test.p -b > c:\Test.txt