Tag Info

Hot answers tagged

8

You can do this with gdb: commands ni and si run a single instruction at time. Command n runs the next line of code, for most values of "next". For n (and the corresponding s) you have to have compiled so that debugging symbols appear in the executable. This stackoverflow answer gives a couple of methods of doing this more-or-less visually. The gdb ...


5

SIGTERM is the way to go in my opinion. It has works in most of the cases. The ones in which this will not work, you'll have to do a SIGKILL anyway. SIGTERM gives process enough opportunity to release all the resources it has to and shut down cleanly.


5

As vinc17 says, there’s no reason for this to happen.  When you type a signal-generating key sequence (e.g., Ctrl+C), the signal is sent to all processes that are attached to (associated with) the terminal.  There is no such mechanism for signals generated by kill. However, a command like kill -SIGINT -12345 will send the signal to all processes in ...


4

According to the exit man page from The Single UNIX® Specification, Version 2: The parent process ID of all of the calling process' existing child processes and zombie processes is set to the process ID of an implementation-dependent system process. That is, these processes are inherited by a special system process. For most Unix variants, that special ...


4

How CTRL+C works The first thing is to understand how CTRL+C works. When you press CTRL+C, your terminal emulator sends an ETX character (end-of-text / 0x03). The terminal is configured such that when it receives this character, it sends a SIGINT to the foreground process group of the terminal. This configuration can be viewed by doing stty and looking at ...


4

Run ps -l on the process ID and check the S (“state”) column. If the state is R, then your process is executing code. If the process remains in state R and strace doesn't show it executing any system call, then the process is trapped in a very long, possibly infinite computation. If the process is and remains in state D, then it is blocked in a system call. ...


3

As always it depends... Typically when I install Debian I start with a minimal installation and add to that what I need and want to run. Anything that gets started automatically then is supposed to be running. You may have installed and enabled (much) more than YOU need, but randomly killing things is the wrong way to reduce any potential overhead. Check ...


3

1) This is pager or swapper: Which process has PID 0? 2) Never used Minix but manual says negative pid in Minix means kernel process. As this is actually part of the kernel implementation, I can't say if that comply or not to POSIX =) 3) You should use pid_t If your aim is maximum portability you should read POSIX and it says: First, getpid() function ...


3

Try: pidof bash | xargs ps -o rss,sz,vsz To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own: ps -o rss,sz,vsz <process id> From the man page: RSS: resident set size, the non-swapped physical memory that a task ...


3

This should work for a bash script. It will abort execution of the script if another instance of the external software was found. The key here is `pidof. #!/bin/bash # Abort startup if another instance was found pidof /path/to/software.executable > /dev/null && { echo Sorry. Only one instance allowed. exit } Alternatively you could use ...


3

I don't have access to a BSD machine to check but your ps command should work as advertised. In any case, as a dirty hack, you could always just parse the output of the full ps (where NNN is the PID you are after): ps aux | awk -v OFS="\t" '$2=="NNN"' Or, to keep the output format identical to that of ps: ps aux | grep -i '^[a-z ]*NNN ' You may have ...


3

In this context, an "instance of Emacs" refers to a single process. No, Emacs doesn't hold a thread for each open buffer. My current session has 129 open buffers (some 100 opened from files, the others being output buffers for certain subordinate processes - python, ruby, elixir interpreters, wanderlust folder and summary views, flycheck-mode syntax ...


3

There must be some kind of misunderstanding. cryptsetup luksFormat doesn't do anything time consuming. It writes a LUKS header which, with one key slot is only like 128kb or so in size. Writing that is pretty much an instant operation. The most time (around 1 second) is spent on hashing your passphrase with many iterations to make bruteforce unviable. As ...


2

There's no reason to propagate the SIGINT to the child. Moreover the system() POSIX specification says: "The system() function shall ignore the SIGINT and SIGQUIT signals, and shall block the SIGCHLD signal, while waiting for the command to terminate." If the shell propagated the received SIGINT, e.g. following a real Ctrl-C, this would mean that the child ...


2

Are lock, mutex, and semaphore for between threads or between processes? You'll find examples of locking primitives for both situations. For example, pthread mutexes are used for mutual exclusion between threads of the same process. On the other hand, System V IPC (man svipc) semaphores can be used across processes. Filesystem-level locks (on files or ...


2

Moving my comment to an answer.... I don't believe there are exceptions. Found this "sometimes the parent process is killed before its child is killed. In this case, the "parent of all processes," init process, becomes the new PPID (parent process ID). Sometime these processes are called orphan process." source Similarly is described in IBM's blog: "The ...


2

I don't believe so. It always goes to the init process. http://en.wikipedia.org/wiki/Orphan_process


2

You want to run a background job that's isolated from its caller. This sounds a lot like a daemon. Unfortunately, there's no standard utility to start a program as a dameon. Debian and derivatives provide start-stop-daemon, but that's unfortunately not portable to other distributions. You can install daemonize, which will run on most unix variants.


2

Your script seems good enough. There are just some improvements needed: #!/bin/bash shopt -s nullglob for fd in "/proc/$$/fd/"*; do fd=${fd##*/} case "$fd" in 0|1|2|255) ;; *) eval "exec $fd>&-" ;; esac done exec "$@" nullglob prevents the pattern from presenting itself if no file is found. Globbing or ...


2

From man pstree: pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count, e.g. init-+-getty |-getty |-getty `-getty becomes init---4*[getty] Child threads of a process are found under the parent process and are shown with the process ...


2

In the Linux kernel, each process is represented by a task_struct in a doubly-linked list, the head of which is init_task (pid 0, not pid 1). This is commonly known as the process table. In user mode, the process table is visible to normal users under /proc. Taking the headings for your question: Process identification data is the process ID (which is ...


2

When you run the script with: bash /tmp/test0& you're starting an entirely separate bash process and putting it in the background. You can't see the variables defined in that script; they belong to the other process. If you want to get access to variables defined in another file, load that file into your current bash process using the . or source ...


2

pgrep -x script1 | xargs -I pid pkill -x -P pid java Would kill the java processes whose parent process is called script1.


1

Some probably are. A few might not be. If you check ps fxa, you'll see a lot of them are children of [kthreadd] and have names also in brackets. Those you can mostly ignore (they're part of the Linux kernel). Other than those, you'll have to research each individually. Some (e.g., init) are critical. Others are critical depending on how you use the server ...


1

You can instruct init to run only one instance of your software — in fact, that will happen naturally if you start your software from init. But init's job has nothing to do with preventing other programs from starting other instances of your software. If you want to ensure that only a single instance of your program runs, then instead of running your ...


1

There may be a more elegant way of doing what you want, but this works: do (cat /var/run/out& echo $! > cat_pid; wait) | (nc -l 8080 <&0 & echo $! > nc_pid; wait) > >( ︙ (broken into separate lines after the | for readability).  This works by wrapping each command whose PID you ...


1

This is not possible. I usually do CTRL-Z and %1& or bg 1 where '1' is the job number. If you have a separate terminal and know the process id, you can do kill -20 500; kill -18 500 (if your process id is 500) to first suspend and then start in background.


1

What you are asking is not possible. You can however do the following [usr@localhost:~]$ sleep 100 & [1] 28542 [usr@localhost:~]$ fg sleep 100 ^Z [1]+ Stopped sleep 100 [usr@localhost:~]$ bg [1]+ sleep 100 & [usr@localhost:~]$ jobs -l [1]+ 28542 Running sleep 100 & Another alternative is to use screen or tmux


1

Make a cron file for root via sudo crontab -e, add the line: 0 0,12 * * * /etc/init.d/crtmpserver restart This will restart the server each day on 00:00 and 12:00. Change the '0' and '12' to make it happen at different times.



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