Tag Info

Hot answers tagged

59

When a process exits, all its children also die (unless you use NOHUP in which case they get back to init). This is wrong. Dead wrong. That person has been lying to you, either when they said that or when they said they knew something about Unix and processes. There are two ways in which the death of a process can indirectly cause the death of its ...


33

I knew I was grasping at straws, but UNIX never fails! Here's how I managed it: bash$ gdb --pid 8909 ... Loaded symbols for /lib/i386-linux-gnu/i686/cmov/libnss_files.so.2 0xb76e7424 in __kernel_vsyscall () Then at the (gdb) prompt I ran the command, call write_history("/tmp/foo") which will write this history to the file /tmp/foo. (gdb) call ...


11

However, are there any other clever tools/methods to see if process listening on TCP port receives a message? You can use strace with -e trace=network. This is what it prints on accepting a TCP connection, receiving an HTTP request, sending an HTTP response and closing the connection: $ strace -v -f -e trace=network -p `cat logs/my_server.pid` Process ...


8

When a process exits, all its children also die (unless you use NOHUP in which case they get back to init). This is correct if the process is a session leader. When a session leader dies, a SIGHUP is sent to all members of that session. In practice that means its children and their descendants. A process makes itself session leader by calling setsid. ...


8

There are a number of possibilities (some mentioned in other answers): A system or user cronjob executing often, In SysV init, an /etc/inittab entry for the service with the respawn directive, In systemd, a unit file with the Restart option set to a value other than no, In Upstart, a service configuration file with the respawn directive, A process ...


7

Check the kernel documentation for information about files in /proc. There is one such file per process because not all processes see the same mount points. Chroot is a traditional Unix feature that makes it possible to restrict processes to a subtree of the filesystem tree. A chrooted process would not see mount points outside its root. Linux takes this ...


6

On Linux, the file is not locked even when a program is writing to it (unlike windows). To check if the process is completed, use: while [[ 1 ]]; do pgrep dbprocess &>/dev/null if [[ $? -eq 0 ]]; then echo still running else echo finished # start ftp transfer fi sleep 2 done To check if the process has the file open, you can ...


5

Since the command is still running in screen, its parent bash has not reread any history so: reattach to screen press ^Z then up arrow bonus: wrap the command in single quotes (navigating with ^A^A - because screen(1) - and ^E) and echo + redirect into a file fg to pursue command execution There are caveats, but this is useful enough, most of the time.


5

You can use the wait shell built-in to accomplish this. The wait builtin simply causes the shell to pause waiting for background jobs to complete. You can either pass it a specific job to wait for, or have it wait for all jobs. For example: echo $(date): starting sleep 5 & echo $(date): do something else wait echo $(date): background job finished ...


5

Starts automatically with another process id means that it is a different process. Thus there is a parent process, which monitors its children, and if one dies, it respawns it again. If you want to stop the service completely, find out how to stop the parent process. Killing it with SIGKILL is of course one of the options, but probably not The Right OneTM, ...


5

I believe you could use pstree. You could specify the command as, pstree -p PID The above will give you a list of all parents of the java applications.


4

I'd like to expand on Davidann's answer since you are new to the concept of a cron job. Every UNIX or Linux system has a crontab stored somewhere. The crontab is a plain text file. Consider the following: (From the Gentoo Wiki on Cron) #Mins Hours Days Months Day of the week 10 3 1 1 * /bin/echo "I don't really like cron" ...


4

The value can only be extended up to a theoretical maximum of 32768 for 32 bit systems or 4194304 for 64 bit.


4

You could have a look at its PPID (parent process ID) : $ ps -eo pid,ppid,args | grep java Once you've got the PPID (second column) of your Java process, use ps again to find the associated process: $ ps -p [PPID] Edit : if the parent is 1 (init), then the first parent of your Java process died right after "giving birth" (how sad). Because of that, you ...


4

Linux-specific answer: perf-tools contains an execsnoop that does exactly this. It uses various Linux-specific features such as ftrace. On Debian, its in the perf-tools-unstable package. Example of me running man cat in another terminal: root@Zia:~# execsnoop TIME PID PPID ARGS 17:24:26 14189 12878 man cat 17:24:26 14196 14189 tbl 17:24:26 ...


3

You could use the -o switch to specify your output format: $ ps -eo args From the man page: Command with all its arguments as a string. Modifications to the arguments may be shown. [...] You may also use the -p switch to select a specific PID: $ ps -p [PID] -o args pidof may also be used to switch from process name to PID, hence allowing the use ...


3

The first column mean the signal that is sent. Use kill -l for a list of all signal that are available on your system (see the oracle documentation for the meaning of the signals, here the most important ones). The second column indicates whether the signal is caught by a signal handler of the process or not. caught means that there is a signal handler ...


3

Workaround using GNU parallel. parallel --nonall --sshloginfile .cluster --tag w In my case I use a file .cluster, which contains the hostnames where I want to run the command: $ cat .cluster n04 n05 n06 My output n04 11:19:43 up 110 days, 20:54, 2 users, load average: 0.16, 0.24, 0.25 n04 USER TTY FROM LOGIN@ IDLE JCPU ...


2

If you know the listening port of the process, you can use fuser with -k flag. Something like, fuser -k 3002/tcp


2

Take a look at this script https://github.com/pixelb/scripts/commits/master/scripts/ps_mem.py which we are using regularly to debug our applications. It is not a simple task and the methods differ from kernel to kernel sometimes. From the description of the script you can read the following. # Try to determine how much RAM is currently being used per ...


2

This is almost certainly implemented by the program itself, and probably impossible for the OS to force for all but the most rudimentary programs. If, however, you know the manner by which the program decides that it is already running, and that manner is something you can influence, then you can indeed get an executable to launch a new process (or not). ...


2

You could do something like this to start a process with the desired PID. while true; do bash -c '[[ "$$" == 99999 ]] && echo PID is 99999'; done You can wait until you get the desired PID and probably replace the echo statement to whatever you actually need to test. References will the same pid be used after getting killed? EDIT Why the ...


2

Your script does not have /tmp/console_test opened, the cat process does. Your script is reading from a pipe that is connected to the cat process; that's what you're seeing in your question. Search for the cat process and check that one out. You probably want something like this: while read x; do echo "received $x" eval "$x" done < ...


2

Try something like this: (example output from busybox on OpenWrt on one of my routers) root@ap8:~# xargs -0 printf '%s\n' </proc/991/cmdline /usr/sbin/uhttpd -f -h /www -r ap8 -x /cgi-bin -u /ubus -t 60 -T 30 -k 20 -A 1 -n 3 -N 100 -R -p 0.0.0.0:80 -p [::]:80 /proc/$PID/cmdline contains the arguments of process $PID like a C-ish strings one after ...


2

This is from the ps manpage: 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 ...


1

Why execution times of the same binary differ on multiple executions The key problem here is the non-deterministic behavior due to the way the CPU works. Modern superscalar CPUs can execute multiple instructions at a time or change the order of commands to be executed (out-of-order execution). Regarding your example, it's also possible that optimization in ...


1

Whatever you are trying to do there is most probably the better approach, but if you are determined something like while [[ 1 == 1 ]]; do sleep 10000& done will start many sleeps, but it may take a while to start all of them. When you will have enough processes just hit Ctrl-C to exit while loop.


1

A process is an instance of a program. A program can be instanced several times, that is, several processes can be created with the same executable code loaded. I would like to quote a line from Understanding the Linux Kernel by Daniel P. Bovet and Marco Cesati: It is important to distinguish programs from processes; several processes can execute the ...


1

Natively, several processes can be run with the same executable code. If this isn't happening naturally then yes, the program itself made it happen. However, I couldn't tell you how this is done on a Windows (or at least, Windows-quite-like) system. On Linux, we mostly use .pid files. Is it because the exe file runs as a server? Well, this could also ...


1

In general, no. If a program never calls execve, you have no opportunity to intercept anything, unless you manage to write code to preload over a symbol, but I'm not sure that even works with WINE.



Only top voted, non community-wiki answers of a minimum length are eligible