I have a C++ Qt application which works with daemon (spnav) - receives X11 messages from it. Is it possible to receive some kind of notification, if daemon crashes? I know that I can create loop in separate thread, but I must operate only with one thread. Does Linux (or X11, or someone else) send any broadcasts when application crashes?
Thanks to #y_ug, I have found a solution - start the daemon process as a child of my program.
Related
Is it possible to get HANDLES of all running processes of my application?
I need to send message to all currently running processes of my application. Every process may execute from a different location (folder/filename) and may be a different version of the same application. Other applications should never receive my messages.
Originator itself shouldn't receive a message, only other instances should receive a message. New instances of my application start in future also should communicate with other currently running copies.
Main window class and name may differ, so FindWindow() is not a solution for me.
How can I do this? What is the best way to solve this task?
I have C++ app is running on my device which is a bit modified version of Raspberry PI. Application is reading data from a serial port and I need a device to reboot after some particular data is received. I've been wondering about integrating this functionality with watchdog but have no idea how to do it. Maybe there is a possibility to send some signal from my app to watchdog to tell that it's time to reboot?
P.S. Application starts as systemd service.
Call
std::system("sudo reboot");
Why would you do this that way? The reason one uses watchdogs is exactly what Marco described. If a system does not respond the watchdog triggers. Typically this is needed because devices that are lets say turned off do not send anything anymore, therefore you need some kind of trigger to let your system know it should reboot. Here you already get your trigger from the incoming signal therefore the watchdog is redundand. Simply reboot after you have received your data.
Watchdog is great if you want your device to reboot autonomously when your software blocks or Is not reachable anymore
If that is what you want to achieve watchdog is the right choice.
I was reading about pipes today, it seems an interesting for me to use it or to start about it.
but it's written there that the processes should be like a parent and child or client server and the communication will be between them.
there are some things I don't understand and before start I should be sure about them.
If I have a running process for example on my machine, and I want to send message to it, of course I can't control it, so how can I make it respond to my messages??
should I create the client and server and run them both??
Or the running process application can be a server for example and I can send some events to it??
if you can help me in this :)
thanks :)
If the running process is reading from stdin, you may write to /proc/the_pid/fd/0 to send your message.
I am searching for a way to close a process running under any user by a windows service running under the system account. I've nearly tried everything but I could not find any solution except killing the process.
Why can't I kill the process?
I can't kill the process uses a tray icon. If I kill the process, the tray icon won't disappear.
What I've tried so far
I've already tried to use global eventhandles (did not work because the child process got extremely laggy).
I also tried to use PostMessage/SendMessage to communicate with the process. That solution did not work because a windows service can not interact with any user interfaces,...
I found another question (here on stackoverflow) which describes exactly my problem: Close a child process from a windows service.
This question does not contain a nice solution.
First of all I don't use C++ instead of C#. The next problem is, that the child process uses a mouse hook. So it has so run very fast without many overhead. Otherwise it would get laggy which would mean, that the mouse would lag on the whole system.
So is there really no simple solution to close a process from a windows service?
A service can use SetProcessWindowStation() and SetThreadDesktop() to attach to the interactive desktop of the target process before then sending messages to the target process.
Alternatively, the service can use CreateProcessAsUser() to run a new process in the same session as the target process, and then that process can send messages to the target process.
I am getting intermittent errors -
child process XXX still did not exit, sending a SIGTERM.. and then a SIGKILL. It occurs intermittently and the web page hangs.
I was not using Daemon process..but now I am, still the problem exists..
Also I have some Error opening file for reading: Permission Denied.
Please can someone help?
I am new to this forum, so sorry if that has been answered before.
If you were not using daemon mode of mod_wsgi, that would imply that Apache must have been restarted at the time that initial message was displayed.
What is occurring is that in trying to do a restart, Apache sends a SIGTERM to its child processes. If they do not exit by their own accord it will send SIGTERM again at 1 second intervals and finally send it a SIGKILL after 3 seconds. The message is warning you of the latter and that it force killed the process.
The issue now is what is causing the process to not shutdown promptly. There could be various reasons for this.
Using an extension module for Python which doesn't work in sub interpreters properly which is deadlocking and hanging the process, preventing it from shutting down. http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
Use of background threads in the Python web application which have not been set as being daemon threads properly with the result they are then blocking process shutdown.
Your web application is simply trying to do too much on process shutdown somehow and not completing within the time limit.
Even if using daemon mode you will likely see this behaviour as it implements a similar shutdown timeout, albeit that the timeout is configurable for daemon mode.
Anyway, force use of the main Python interpreter as explained in the documentation link above
As to the permissions issue, read:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Working_Directory
In short, ensure access permissions are correct of files/directories you need to access and ensure you are always using absolute path names when accessing the file system.