1

I was running gedit from the command window for editing an xml file. After editing the file, I closed the gedit text editor window.

But the gedit process was till running in the command window. So I forced stopped it using ctrl+z.

After that I want to use gedit to open another file. How-long-so-ever I try, gedit xxxx.xml, gedit is not responding.

Can someone help me why it is not responding? And how to go forward?

1
  • 3
    <Ctrl+Z> is suspend for process, then you need to send it to background with bg. If you need to stop process, use <Ctrl+C>.
    – N0rbert
    Aug 3, 2018 at 9:01

2 Answers 2

4

Find PID of gedit

There is 2 way to find the PID of gedit :

  • Open a terminal, type for example ps -x (you can also use top, htop, ...)

    enter image description here

    Here, we can that my gedit PID is 16694 (it's on the 1rst column on the left)

  • using pgrep, you don't have to concate 2 command (ps + grep) :

     pgrep gedit
    

    This command return you the PID of gedit


Force gedit to close

use the command kill -9 PID where PID is the number you find with ps -x. In my example, gedit PID was 16694, so I must type kill -9 16694

You can now restart gedit, the non-responding state is totally wiped out.

NB: kill command works even on program open with & or nohup option.

NB-2 : If you have some applications running, it could be hard to find the PID, so just add a grep command to find it like that :

ps -x | grep gedit
2
  • look at pgrep as well instead of ps -x | grep ….
    – DK Bose
    Oct 31, 2019 at 15:29
  • More on pgrep here.
    – DK Bose
    Nov 15, 2019 at 10:18
3

Ctrl+Z means suspending the process, so it continues to live but appears frozen. It is not terminated as Ctrl+C would do.

There are basically four options what to do with a process suspended in a terminal:

  • fg %<job> to continue it running in the foreground
  • bg %<job> to continue it running in the background (so you can issue further commands)
  • kill %<job> to terminate the process gracefully
  • kill -9 %<job> to terminate the process forcefully (can cause unsaved changes etc.)

<job> is to be replaced with the job number given by the shell in square brackets (it’s 1 in the following example):

$ sleep 30
^Z
[1]+  Stopped                 sleep 30
$ kill %1
$ # (enter any command or just press Enter to refresh the shell)
[1]+  Terminated              sleep 30
$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .