Killing a process windows CE - windows-ce

I need to implement a program that will run on Windows CE 6.0, in C++, and that aims to kill a specific process at a specific moment.
I have tried to use 'TerminateProcess(ProcessHandle, ExitCode)'. It works, and kills the process whose handle I passed. However, when killing the specific process I want to kill, the machine stops responding, which is not acceptable.
I can kill the process via tellnet, if I use:
telnet 10.120.12.5 (IP of the Windows CE machine)
shell -d
kp 6522589 (example ID of the proccess)
That works. It kills the process and the machine does not stop running.
So the question is, how can I insert this command into my code? or, how can I call a script which does this from my code? (the script will have to be stored inside the windows CE machine).
Any other suggestion will be welcome.

How do you get the ProcessHandle? You usually need to free it with CloseHandle() after you are done with it (after calling TerminateProcess()).
You can use CreateProcess() to run another program, e.g. the shell/kp program.

Related

Linux command on wake up from hibernate/suspend

I'm new to Linux and running Mint. I've seen a lot of documentation on creating commands that run when the os is started up from the computer being powered off. Is there a way to make similar commands to run when the os wakes up from hibernate or suspend? (For context, I'm running 'rfkill block bluetooth' on startup and would like to when my pc wakes up from hibernate as well).
place your commands in a script file and ensure you have sufficient owner/permissions to execute in /lib/systemd/system-sleep/ so once your OS suspends from sleep, its going to execute.
For more information
man systemd-sleep
https://askubuntu.com/questions/226278/run-script-on-wakeup

Start process via SSH and GDB?

This question sounds very stupid to me, but if this is somehow possible it would be really helpful.
My application is crashing and I need to debug it. And I run this application in another computer, via SSH (it's an HTTP server). If I could leave a terminal running the application over GDB and SSH all the time, I'd be able to find the bugs. But I don't have a free computer to do that. What can I do? Is there a way to start GDB with nohup(1) plus &> and stuff like that, so I can see GDB output (where command, for example) later?
A classical Unix program called screen is your friend (or its competitor tmux). It allows to keep a virtual console open across multiple logins:
screen
starts such a session; using you can detach from that; using
screen -r
you can reconnect to it later.
However, you don't even need that; just make your program leave a core dump when it crashes; ulimit -c unlimited says "every program that crashes leaves a core dump"; you can then just open the core dump using gdb later on, and everything will be as if you ran the program inside gdb when it crashed.
gdb core.123456

Google Chrome hanging in CentOS 7

I am using Linux platform (CentOS 7). sometimes i get my system just hang and then i need to do restart my system directly from power so anyone know how to rectify this issue without restart my system.I am fed up with every time restart my system. so please help me out.
I know here i will get my answer that's why i posted my question here.
Thanks in advance!!!
You can goto text mode and kill the process which process are running in your system,
Press CTRL+ALT+F2 and goto textmode.
Type your username and password
Write command ps -eaf|grep chrome (you can see here which process is
running and take that process number just like task manager in
windows)
Now need to kill that process so Write command kill -9 [process#]
once process will kill you can comeback again in graphics mode with
CTRL+ALT+F1
I hope this this answer will helpful for you beacuse this process is work fine for me when my any application stuck. :)

Difference between linux and windows process

In linux we create a process using fork and exec ant while in windows we use createprocess .My teacher told that linux method of creating process is more robust than windows why?
Fork & exec are direct calls to the kernel whereas createprocess goes through window api to access kernel.
There might be more various reasons but this is what I have on top of my mind :)

Launch process from CGI in Linux

I need to launch server executables from terminal. They are running through wine (because those executables are for Windows) in the background. If I launch them normally, from Terminal, those work without any problem.
Now I'm trying to make CGI (bash) script and launch servers from website, but script doesn't launch processes. I thought that it has something to do with wine, but no, script doesn't launch any processes at all.
I'm building that system on Ubuntu 12.04.1 LTS, after that scripts would go onto Debian server.
So, the question is: is it even possible to run background process from CGI scripts? If yes, would you please explain how?
A CGI program is like any other program, except that it is supposed to run quickly and to follow the CGI protcol (in particular, regarding to stdout output).
As with any other Linux program, you can (subject to limitations and permissions on your system) run processes, using syscalls like e.g. fork(2), execve(2) and many others.
I suggest to read a good Unix programming book like Advanced Unix Programming abd Advanced Linux Programming. We can't teach all that here in a few minutes.
You could also run processes using the library system(3) and popen(3) functions (of course these functions are implemented using syscalls, inside GNU libc)
Don't forget the stateless property of CGIs; you may consider using FastCGI or SCGI instead.
(A program started thru wine from a CGI might fail, e.g. because it has no X11
server to talk to; For C# programs, consider Mono on Linux).
Another possibility could be to run Windows in some VM, and have your CGI interact with such virtualized Windows programs. Not knowing Windows, I have no idea about the issues of such an approach.

Resources