More terminals on cygwin - cygwin

I want to have one more terminal on cygwin.
Basically I am working on programs related to process. I just want to see all the process when the parent is running.
How can I do that?

I got the answer. I did launched the main program in background like this (This program creates a zombie child)
./make-zombie.exe &
And was able to see the child and parent process...
$ ps -e pid,ppid,stat,cmd
PID PPID PGID WINPID TTY UID STIME COMMAND
5052 1832 5052 5224 pty0 27510 16:50:04 /home/process/make-zombie
1832 4852 1832 4068 pty0 27510 16:49:49 /usr/bin/bash
3332 5052 5052 3332 pty0 27510 16:50:04 /home/process/make-zombie <defunct>
4852 1 4852 4852 ? 27510 16:49:49 /usr/bin/mintty
3656 1832 3656 3080 pty0 27510 16:50:19 /usr/bin/ps

Related

Change process title/name in bash script

There is a field in process object in node.js: process.title
That field allows you to change process name displayed in top or ps command on linux.
Is there some way to do this for and in bash script also?
Changing the command line reference from running processes is possible on *NIX with /proc filesystem :
$ ps
PID TTY TIME CMD
106 tty4 00:00:01 bash
719 tty4 00:00:00 ps
$ echo "toto" > /proc/106/comm
$ ps
PID TTY TIME CMD
106 tty4 00:00:01 toto
719 tty4 00:00:00 ps
$
And yes, it's not the prettiest way to do so.

Different PID for the same process

I am just trying to understand more about the PID column when running the ps command.
If I have two terminal windows open, in the first one I run the following command
firefox &
Then run the ps command in BOTH and get the following output from the first window
PID TTY TIME CMD
16814 pts/1 00:00:00 bash
16822 pts/1 00:00:04 MainThread
16881 pts/1 00:00:02 Privileged Cont
16938 pts/1 00:00:00 WebExtensions
17026 pts/1 00:00:00 Web Content
17081 pts/1 00:00:00 ps
And the following in the second
PID TTY TIME CMD
16794 pts/0 00:00:00 bash
17082 pts/0 00:00:00 ps
In both outputs we see the shell process. Why do they not have the same PID, even if it has the same process name.

How can I get STAT column in ps command?

I installed Cygwin for 64 bit versions of Windows.and I run "Cygwin64 Terminal" in order to confirm whole process' state. As far as I know, ps command must show STAT column but It is impossible to find STAT column Whenever I execute "ps -l" or "ps aux" ,"ps -ef", "ps axj"..
I really want to view STAT column in ps command because a source code which I practice recently request me to check zombie process by means of ps command.
screenshot of ps command without STAT column
Use procps
$ /usr/bin/procps.exe ax
PID TTY STAT TIME COMMAND
1580 pty1 Ss 0:00 -bash
1624 pty0 R 0:00 /usr/bin/procps ax
1522 ? Ss 0:05 /usr/bin/mintty -i /Cygwin-Terminal.ico -
1599 pty1 T 0:00 less .bashrc
1523 pty0 Ss 0:00 -bash
1579 ? Ss 0:00 /usr/bin/mintty -i /Cygwin-Terminal.ico -
you can find it in procps-ng package
$ cygcheck -f /usr/bin/procps
procps-ng-3.3.16-1

Process found by netstat is not listed in ps command and unable to be killed

I am running MINGW64 command line on Windows 7.
I want to find the process which occupies port 8082 by using 'netstat' and kill it. But an error occurs saying "No such process".
$ netstat -aon | grep 0.0.0.0:8082
TCP 0.0.0.0:8082 0.0.0.0:0 LISTENING 3960
$ kill -9 3960
bash: kill: (3960) - No such process
Then I run 'ps' command but can not find any process with pid 3960
$ ps -a
PID PPID PGID WINPID TTY UID STIME COMMAND
2716 1 2716 884 pty0 197108 09:53:42 /g/Apps/Java/jdk1.8.0_102/bin/java
4696 5248 4696 2740 pty2 197108 11:05:22 /usr/bin/bash
5248 1 5248 5248 ? 197108 11:05:22 /usr/bin/mintty
5256 4696 5256 4032 pty2 197108 11:16:33 /usr/bin/ps
Then try 'taskkill' command, but it is still not working and shows wired characters...
$ TASKKILL /PID /F 3960
▒▒▒▒: ▒▒Ч▒▒▒▒/ѡ▒▒ - 'C:/Program Files/Git/PID'▒▒
▒▒▒▒ "TASKKILL /?" ▒▒▒˽▒▒÷▒▒▒
I am confused and don't know how to kill such a non-existing process.

Bash script hangs if I interrupt it

For example there are
ps -ax
PID TTY Stat Time Command
1 ? Ss 0:00 /sbin/init
.
.
.
1564 ? Sl 0:00 usr/bin/xyz
1569 ? Sl 0:00 gnome-terminal
.
.
1730 ? sl 0:00 gcaltool
1759 ? sl 0:00 firefox
I have to interrupt the process 1564
1564 ? Sl 0:00 usr/bin/xyz
1569 ? Sl 0:00 gnome-terminal
The terminal gets hanged if I interrupt the process PID 1564. I think it hangs because I am interrupting the terminal process. Is there any other way as I have to strace the process
process PID 1730,
process PID 1759,
which were generated at the last?
Any way to bypass the strace and interrupt of the terminal process?

Resources