Tag Info

Hot answers tagged

17

You can stop both processing by sending them SIGSTOP (replace pid1 and pid2 by the actual PIDs or use killall and the application name): kill -SIGSTOP pid1 pid2 The printing on the terminal (or wherever stdout is redirected to) should stop. Then continue one of them using kill -SIGCONT pid1 If the error messages appear immediately, you know its the ...


12

Your program does exactly what you tell it to do: it changes the working directory for itself to /home/enedil/projects/algo. But once it exits, the shell's working directory is restored. I guess what you want to achieve is to change the working directory of the parent process, i.e. the shell, without resorting to a simple cd. There is a method, but as its ...


11

On Linux, assuming you want to know what is writing to the same resource as your shell's stdout is connected to, you could do: strace -fe write $(lsof -t "/proc/$$/fd/1" | sed 's/^/-p/') That would report the write() system calls (on any file descriptor) of every process that have at least on file descriptor open on the same file as fd 1 of your shell.


5

The current working directory is local to the process. So, what you want is not possible.


5

There is big difference between them. ulimit -e only set the RLIMIT_NICE, which is a upper bound value to which the process's nice value can be set using setpriority or nice. renice alters the priority of running process. Doing strace: $ cat test.sh #!/bin/bash ulimit -e 19 Then: $ strace ./test.sh ................................................... ...


5

You can try fuser: fuser -k 4990/tcp Or using lsof to get the process id, then feed to kill: kill $(sudo lsof -t -i:4990)


4

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 ...


4

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.


3

Question 1 : Why is the directory where a program is installed not the initial directory of the process when running the program? Actually, the installation path of a program is irrelevant. What matters is the current path of the father process. In case of a program launched from a shell, the father process is the shell itself so the initial current ...


3

A restart job has to kill an old instance first. What is happening here is that there isn't an old copy to kill. I advise you to try this command instead: /etc/init.d/vsftpd restart


2

ps -eo pid= | sort -rn | head -n1 would be POSIX. On Linux, process ids share the same namespace as the thread ids. There, you can do: ps -Leo tid= | sort -rn | head -n1 To get the highest thread or process id number.


2

This doesn't use ps, but parsing ps is likely to be difficult (not to mention non-portable). This ought to be easier (and at least a bit more portable): ( cd /proc; printf "%s\n" *; ) | sort -n | tail -n 1 That looks for the highest numbered directory inside /proc, which works because on many Unix systems there's one /proc/### directory per pid that ...


2

Well, I do not expect a concise answer than the one available from here. What I understand about 32-bit OS is, the address is expressed in 32 bits, so at most the OS could use 2^32 = 4GB memory space The most that the process can address is 4GB. You are potentially confusing memory with address space. A process can have more memory than address space. ...


2

Look at the documentation for proc(5), and you'll see this for the processes field: Number of forks since boot. So it's simply not the number you're looking for. ps will give you that as you already know, counting the directories with only numbers in their name under /proc is another approach.


1

The documentation for the pam_loginuid PAM module gives a pretty good hint: The pam_loginuid module sets the loginuid process attribute for the process that was authenticated. This is necessary for applications to be correctly audited. This PAM module should only be used for entry point applications like: login, sshd, gdm, vsftpd, crond and atd. ...


1

Basically, it sounds like you want general advice on profiling an application's I/O at runtime. You've been doing this with /proc/$PID/io which will give you some sort of idea of how much bandwidth is being used between disk and memory for the application. Polling this file can give you a rough idea of what the process is doing but it's an incomplete picture ...


1

You can start command in background then get its pid via $! variable. Example: $ ls & cat /proc/$!/io [1] 6410 rchar: 7004 wchar: 0 syscr: 13 syscw: 0 read_bytes: 0 write_bytes: 0 cancelled_write_bytes: 0


1

Depending on whether you want to include threads or not, add the -L option to your ps command: $ ps -A --no-headers | wc -l 359 $ ps -AL --no-headers | wc -l 967 Threads are not listed separately by ps by default. The point of threads is that they are multiple threads of execution inside one process address space.


1

Changing process groups has no effect on the process hierarchy. The parent is still P0. It's important that the process hierarchy stays the same. When a shell implements job control, each job is put in its own process group. But the shell must still be the parent of the process group leader, so that the shell gets a SIGCHLD signal when it exits.


1

You can also use the CDPATH environmental variable. As explained in man bash: CDPATH The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command. A sample value is ".:~:/usr". So, for example, you could add ...


1

Run dtruss to see what system calls a process is making: dtruss -p55761 This will tell you what system call the process with PID 55761 is currently engaged in. If that system call accesses some file descriptor, lsof will tell you what file is open there. lsof -p55761 If the file is a pipe or socket, I don't know how to find what if anything is on the ...


1

I believe you are making it more complex than it needs to be. No need for awk or ancient version of ps command. Try this: for x in `ps -ed -o pid=`; do echo -n "$x " ; pargs -l $x; done Or when pretty printed: for x in `ps -ed -o pid=`; do echo -n "$x " pargs -l $x 2>/dev/null # don't want to see err msg for procs that no longer exist done ...



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