Way other than Ctrl+C to stop a command? - c

I tried to run a script in Terminal that led to the following recurring code:
Recurring code:
When I try to press "Ctrl+C" this will stop the command from running on the screen, but if I open Terminal again, the command recurs over and over again. I tried various scripts to kill the process, but nothing is working. Any advice?
Thanks.

Related

CLion not running in Terminal

There's this bug with the placement of certain characters in the embedded terminal in CLion (the Run tab that pops up when you click the Run button), and I figured out that if I changed the terminal in CLion, that wouldn't happen. I changed the terminal to cmder, and it is all working now, except one thing: I can't figure out how to make CLion run the program to that terminal.
I tried changing the configuration, but all it did on run was open cmder but not execute the program (I had to run it manually, by writing the file name).
I wonder, what's the way to fix this, and make CLion directly run C programs on the terminal, instead of the Run tab?
Thank you.
The CLion run configuration always runs in the integreted run window. That is not a terminal emulator, and it cannot be changed so that it runs in an actual terminal emulator (like cmder).
Your best bet is to try to fix the "character placement" in the run window. Maybe ask a different question where you explain the issue, or if it's a clear bug, file a bug report for it.

Stop a PowerShell script GUI while in a loop

I have a PowerShell script for which I've done a GUI.
Every time a do or for loop is running the GUI becomes unresponsive and have to wait until it's done before I can close the GUI or press any other button.
The problem is anoying when for any number of reasons the loop runs infinitely and the only way to stop it is to kill PowerShell from task manager.
I've tried using break but this causes some sort java error although it stop and kills they gui...but I don't want to have the error.
If I use break in the script without GUI the script stops.
Is there a way to have the GUI responding when a loop is running and to stop the script when ever I what it to stop?
You could run the PowerShell script as a job and have the GUI polling the status of that job (in a loop with so you can still react on user input).
Cancelling a script is then also possible by just cancelling the job.

check if subprocess is running via cmd

I am trying to detect if a subprocess in currently running via CMD, But I have no idea how to do that, I know how to detect a normal process, but not a subprocess
any ideas?
EDIT: I am running a program, if the program finishes it opens a new window, i want to detect when that window opens
If the window only shows up when the program closes, then you could check if the program is still running, and if not running, then the window will be shown.
To check if program is running, use one of these solutions:
How to check if a process is running via a batch script

Jenkins task to switch on monitor if it's switched off

I use Jenkins to run our builds. What I want to do is to wakeup the monitor before build starts. This is what I have done so far.
Use nircmdc.exe (http://www.nirsoft.net/utils/nircmd.html) and prepare a batch file to turn on monitor. I have tested the script through command prompt and it works fine.
Then I add a build step in Jenkins to execute windows batch file before running the ANT script. Then I remote start the build (via URL). Console shows that the batch file is being executed. But the monitors doesn't wake up.
Then I included a target in ANT to execute the same batch file and tested running the ANT via CMD. This wakes up the monitor and continue with the build steps.
But, if I run this ant script from Jenkins, everything works fine except waking up the monitor.
Is this something to do with privileges ?
Has someone done something similar?
Don't think I've ever heard of a requirement to wake up the monitor, so probably no one has done anything like this.
However, your problem is probably due to Jenkins process running in a separate session from your machine's console. Have a look at my answer here: Open Excel on Jenkins CI, it explains how to get around the session issue.

Issue with program executed by crontab

I've coded a program in c for an embedded system (Devkit8000, which is a clone of the well known BeagleBoard) running Angstrom Linux.
The program creates a couple of threads, on of them is responsible of taking pictures with a camera connected to the board, and right now the second thread only moves that images to another path. The program should be running during the whole day, and the only way to stop it is sending a signal.
I edited the crontab to launch the program in a specific hour and to send a signal when it has to stop, the issue is that launching the program in this way cause the process to be killed after some time running, but, if i launch the program manually (through the command line), it works perfectly and dont get stopped.
I have no idea about the reason of this different behaviour between crontab and command line. I've checked the system logs but didnt find anything useful. I've also been reading a little and find that the OS can kill a process if it is using so much resources, but doesnt make sense that this happens in only 1 scenario (crontab vs manually)...
Any clue about what is happening?
Thank you in advance!
The main difference is that running a job through cron invokes a non-interactive non-login shell. The effect of that depends on the default shell for your user. For example, if you are using Korn shell or Bash then your .profile will not be executed, as it would on an interactive login shell. Korn shell 88 will execute .kshrc (the $ENV file) but ksh93 will not.
So, a good start might be to call your program from a script, after first "sourcing" your .profile file:
. $HOME/.profile
Failing that... When you say that the process is "killed", do you get such a message? If so, then that sounds like someone sending SIGKILL, i.e. kill -9. If not, then maybe you could run strace or ltrace to find out at what point it dies.

Resources