What to do when Ctrl-C won't kill running job?

1
...
0 0
2
Feb 9, 2011

Ctrl-c doesn't always work to kill the current process (for instance, if that process is busy in certain network operations). In that case, you just see "^C" by your cursor, and can't do much else.What's the easiest way to force that process to die now without losing my terminal?

Summary of answers below:Usually, you can Ctrl-z to put the process to sleep, and then do "kill -9 process-pid", where you find the process's pid with 'ps' and other tools.On Bash (and possibly other shells) you can do "kill -9 %1" (or '%N' in general) which is easier. If Ctrl-z doesn't work, you'll have to open another terminal and kill from there.

Ubuntu Servers :: Writing Init Script - Signals To Kill The Process (Ctrl-C) From A Bash Script And Exit Dtach (Ctrl-`) CentOS 5 :: Why 'ctrl+a, K' Nor 'ctrl+a Kill' Doesn't Work For Screen Windows? Software :: Unable To Kill Process With Kill -9 General :: Kill The Process In Different Group But Not One-by-one? General :: How To...
0 0
3

Just in case this helps someone else -- most people are here because they have some stopped processes that they started, backgrounded via the shell maybe. I needed to find processes, as root, stopped by other users, for which variants on the jobs command won't do.

A bit of digging around with man ps got me to this:

ps -a -o pid,user,cmd,state | grep 'T$'

Explanation: the -a flag says show all processes, then -o controls output, what info will be shown about each process. I'm choosing pid, user, cmd (the command line), and state, which is the process state.

From man ps:

PROCESS STATE CODES Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process: D uninterruptible sleep (usually IO) R running or runnable (on run queue) S interruptible sleep (waiting for an event to complete) T stopped, either by a job control signal or because it is being traced...
0 0
4

Answer

Ctrl+C sends SIGINT, which can be trapped and handled or ignored.

The behavior of programs that are interrupted from the keyboard or other event is mediated by the operating system and so is not merely a python issue but would arise in C++, Java, JavaScript, etc. It can also differ somewhat between Linux/Unix and Windows. The usual default behavior is to stop the running process, and if there are complex storage or other procedures underway that should not be interrupted it is up to the programmer to set appropriate handlers or options with the OS. Even so, there are other mechanisms that can kill the process running the script. For example kill -9 or SIGKILL can not be trapped or handled.

For handling Ctrl+C see for example Python: Catch Ctrl-C command. Prompt "really want to quit (y/n)", resume execution if no

This is not an instant solution to your needs, but could be simply modified, say to print "Do not use Control+C, instead wait for the program to...

0 0
5

When you have jobs running in Hadoop, you can use the map/reduce web view to list the current running jobs however what if you would need to kill any current running job because the submitted jobs started malfunctioning or in worst case scenario, the job is stuck in infinite loops. I have seen several scenarios when a submitted job got stuck in problematic states due to code defect in map/reduce job or the Hadoop cluster itself. In any of such situation, you would need to manually kill the job which is already started.

To kill a currently running Hadoop job first you need Job ID and then Kill the job using the as following commands:

Hadoop job -list Hadoop job –kill

To list current running job in Hadoop Command shell please use below command:

On Linux: $ bin/hadoop job –listOn Windows: HADOOP_HOME = C:\Apps\Dist\ HADOOP_HOME\bin\Hadoop job list

Above command will return job details as below:

[Linux]

1 jobs currently runningJobId ...
0 0
6

On Windows 7, I have a Java Application, which can start other JAR-s (which are running in background).

In this Application, I have a button, which shoul represent the CTRL+C command for every other started (and still running) JAR-s. I have found this code, which should kill the task by PID (6272):

taskkill /F /PID 6272

But if I run this code on a command propmt, a lot of times it is just waiting, and than return false, so it cannot kill the program. Sometimes it can kill, sometimes it cannot.

I would need a command, which is similar to CTRL+C, because if you hit this CTRL+C, the actual process will end immediately, without waiting!

Could anyone help me please? Thank...

0 0
7

Advertisement

It’s frustrating when programs crash. Everyone has clicked on something in an application, only to have the window gloss over and see the dreaded Not Responding text.

Your first move to kill these frozen programs might be to open the Task Manager Mysteries Of The Windows 7 Task Manager: Why You Don't Need an Alternative , which is perfectly fine. However, if you’d like to do this even faster, you can create a shortcut to instantly kill any unresponsive programs. Here’s how.

The Main Method

To kill off programs without touching the Task Manager, we can use the taskkill command. Typically, you would type this at the command prompt 15 CMD Commands Every Windows User Should Know to kill a specific process. However, it’s clumsy to open up the command line every time a program stops responding, and typing the command every time is a waste. We can do...

0 0
8

I’ve been trying to figure this one out and it’s pretty baffling but I’ve got a bunch of info that may help.

The problem is in winpty, src/agent/ConsoleInput.cc around line 400 where it generates a Ctrl C event. Powershell is easy - PSReadLine disables processed mode and responds to the ^C character. All you have to do is WriteConsoleInput a \x03 and it will work. This has to happen unconditionally though, the processed mode check in winpty makes it not work somehow.

The one that’s got me stuck, and I’ve spent hours in windbg on this, is cmd. Its input loop is basically call ReadConsole and check a global flag if a Ctrl C was generated during the call. Then in another thread, it has a control event handler that sets the flag when the system event is triggered. From the disassembly it looks like it should happen when you call GenerateConsoleControlEvent, but it doesn’t. Or rather, the event clearly goes through, because I can get a “terminate batch job” prompt, but...

0 0
9

We mentioned earlier that typing CTRL-Z to suspend a job is similar to typing CTRL-C to stop a job, except that you can resume the job later. They are actually similar in a deeper way: both are particular cases of the act of sending a signal to a process.

A signal is a message that one process sends to another when some abnormal event takes place or when it wants the other process to do something. Most of the time, a process send a signal to a subprocess it created. You're undoubtedly already comfortable with the idea that one process can communicate with another through an I/O pipeline; think of a signal as another way for processes to communicate with each other. (In fact, any textbook on operating systems will tell you that both are examples of the general concept of interprocess communication , or IPC.) [6]

Depending on the version of UNIX, there are two or three dozen types of signals, including a few that can be used for whatever purpose a...

0 0
10
Ctrl+C sends SIGINT, which can be trapped and handled or ignored.

The behavior of programs that are interrupted from the keyboard or other event is mediated by the operating system and so is not merely a python issue but would arise in C++, Java, JavaScript, etc. It can also differ somewhat between Linux/Unix and Windows. The usual default behavior is to stop the running process, and if there are complex storage or other procedures underway that should not be interrupted it is up to the programmer to set appropriate handlers or options with the OS. Even so, there are other mechanisms that can kill the process running the script. For example kill -9 or SIGKILL can not be trapped or handled.

For handling Ctrl+C see for example Python: Catch Ctrl-C command. Prompt "really want to quit (y/n)", resume execution if no

This is not an instant solution to your needs, but could be simply modified, say to print "Do not use Control+C, instead wait for the program to finish and use the...

0 0
11

Trouble:

It is quite a common problem that Windows Explorer hangs. Windows explorer hangs due any reason like heavy memory resource hogging programs and or any other windows problem. It will give a warning saying

Windows Explorer has encountered a problem and needs to close. We are sorry for the inconvenience

You can restart your windows explorer when it goes to not responding state and continue to work as usual.

Let see how can you restart windows explorer windows process ( Explorer.exe ) and continue working when its got hanged.

Fix:

Follow the procedure below to restart windows explorer

1. Press Ctrl+Shift+Esc to start task manager

2. Click the Process tab and locate Explorer.exe

3. Right click on Explorer.exe and select End Process Tree ( after clicking end process tree you will see nothing other than task manager )

4. Now Click on Applications tab, and click the button which...

0 0
12

The game is over. That game where they get to hire you for 40 years, pay you far less than you create, and then give you a gold watch, and then you get bored, you get depressed, and you die alone.

It wasn’t that fun of a game anyway.

When I had a corporate job I would wake up depressed. I couldn’t move out of bed. The sun would be coming in. A cat on the fire escape staring at me through the window. Even it was more excited to be alive than me. And, by the way, I had the best job in the world. I interviewed prostitutes for a living at three in the morning.

But they were going to kill me in my cubicle.

In 2009 I asked about 10 Fortune 500 CEOs, “did you just use this crisis as an excuse to fire all the people you were afraid to fire before.” Only one said “of course” instantly. The others had to drink more. But then it was admitted: you’re all dead weight and there’s no loyalty.

We’ve entered the “Choose Yourself” era. The era without middlemen....

0 0
13

I feel your pain and have the same basic issue after about 20 hours of play. I've gotten top 10 around 15 times and won the chicken dinner once, but that was by being sneaky and hiding, or surprising people coming through doors vs. winning shootouts. My first 10 games, I didn't kill anyone, then VERY gradually got up to 1-2 kills per game, but those are when I catch someone by surprise, not in a shootout.

Usually I'll win about one out of 10 shootouts (literally), and it's rarely if ever a situation where we're each landing shots, ducking, etc. - it's almost always that I'll put a few shots in but they're still alive, then they fire one shot and I'm dead. I also regularly get one-shotted in a car, but if I fire on a car they never die. I can't remember a time when I one-shotted someone else except with a shotgun to the face from 3 feet away (as they opened a door). Even in cases where I'm crouching in a room and they come in the door, my shot hits but doesn't kill, but...

0 0
14

Introduction

How many times have you been in the situation, during development, you had to kill the current project process for any reason (infinite loops, crazy threads, a wrong return value and so on) ? It happens continuously, I guess.

What to do then? I always have the Task Manager minimized to the System Tray and when I need to kill the project process I click it up, scrolling the tasks list, found mine end kill it. Too much time wasted! ... :)

So it came to my mind to simplify the killing procedure, making it as fastest as possible: Why not having a button in the IDE to do the job for us? An Add-In would help. So here it is.

Background

To understand the source code, it is just needed to read any other Add-in article in this CodeProject section.

The code

The DevStudio Add-Ins Wizard does the main job for us to crate an Add-In, in fact the code you have to implement is simply the one relative to what the...

0 0
15
kill command

Contrary to its name kill is a Unix command to send signals to running processes. One possibility is to request the termination of this process and that's the only case, when the name suits. Usually kill is a standalone utility, but some shells like Bash have built-in kill command.

A signal is a message that one process sends to another when some abnormal event takes place or when it wants the other process to perform some action. Most of the time, a process send a signal to a subprocess it created. This is somewhat similar to the idea of communicating with the other process via I/O pipeline; it is just another way for processes to communicate with each other. That's why signal and pipes are subclasses of a more general concept called interprocess communication, or IPC.

Pipes and signals were available since the days of early UNIX. System V and 4.x BSD in addition implement sockets, named pipes, and shared memory.

Depending on the version...

0 0
16

Ever have an application that just hangs and never returns to normal or terminate?

So you open up Windows Task Manager, find the application process, right click on it and select End Process.

Nothing happens! The process is still running and the dead application continues to cause high CPU utilization to the point where you can't do much with your computer.

You repeat the process. Nothing again. One more time…that process just won't terminate and die.

Now what?

Well, having pesky processes, that refuse to terminate and continues to hog CPU cycles, can be frustrating to the point where you just want to hit the power button and shut down. But that's too risky and more times than not will cause loss of data or system boot problems.

What you need is a utility that can kill and terminate stubborn processes, the first time, using PsKill from Microsoft Sysinternals.

PsKill requires no installation and is a stand alone executable...

0 0
17
Ok, now I'm a little confused. But confusion might not be a bad thing at this point.

It appears that the problem arises when users do multiple Ctrl-Cs in quick succession

So if they only do one ^C, you see the printf() in the signal handler, and if they do more than one, you don't see it? Confusion finds itself upgraded to bewilderment.

The cleanup is not done _in_ the signal handler but enabled by an action taken in the signal handler.

Understood. But is this by manipulation of a semaphore, as through semop() or sem_post(), or is it by using pthread_mutex_unlock()?

If it's the latter, or even if it's the former and this results in pthread_something() being called, then you're might be doing something with pthreads while the pthreads library thinks it's right in the middle of an atomic pthreads operation in the thread which was interrupted. I'm grasping at straws here, but I'm just trying to figure out why this isn't working.

It's tricky...

0 0
18

The expdp and impdp utilities are command-line driven, but when starting them from the OS-prompt, one does not notice it. When you want to kill, cancel, start or resume a job, you will and up in the datapump command prompt… now what?!

All command shown here can be used with expdp and impdp datapump.

Identifying datapump jobs

Do a select from dba_datapump_jobs in sqlplus to get the job name:

> expdp system full=y SELECT owner_name, job_name, operation, job_mode, state FROM dba_datapump_jobs; OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE ---------- -------------------- ---------- ---------- ------------ SYSTEM SYS_EXPORT_FULL_01 EXPORT FULL EXECUTING

Or when you use the JOB_NAME parameter when datapumping, you already identified the job with a name. You don’t need to look up afterwards…

expdp system full=y JOB_NAME=EXP_FULL OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE ---------- -------------------- ---------- ----------...
0 0
19

The expdp and impdp utilities are command-line driven, but when starting them from the OS-prompt, one does not notice it. When you run impdp or expdp and use ‘ctrl-c’ and you want to kill, cancel, start or resume a job, you will end up in the datapump command prompt… now what?!

All command shown here can be used with expdp and impdp datapump.

Identifying datapump jobs

Do a select from dba_datapump_jobs in sqlplus to get the job name:

> expdp system full=y SELECT owner_name, job_name, operation, job_mode, state FROM dba_datapump_jobs; OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE ---------- -------------------- ---------- ---------- ------------ SYSTEM SYS_EXPORT_FULL_01 EXPORT FULL EXECUTING

Or when you use the JOB_NAME parameter when datapumping, you already identified the job with a name. You don’t need to look up afterwards…

expdp system full=y JOB_NAME=EXP_FULL OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE ----------...
0 0