Tag Info

New answers tagged

0

If I understand question 1 correctly, no, there's no stack or list of child processes. Somewhere in the structs that the kernel keeps around for a process, there's a PID field and a parent PID field. When a process exits, the parent PID of the exiting process gets a notification via a SIGCHLD (the default SIGCHLD handler is SIG_IGN, so nothing happens unless ...


0

To do this for the shell, use the source command (aliased to .). It will run the application in the context of the current shell rather than creating a new shell context. This is how you can set environment variables as well. If you notice all of the startup scripts in /etc/rc.d or /etc/init.d, you will see lots of scripts that are included by other scripts ...


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


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


5

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


2

You can refer to the official page: https://www.kernel.org/pub/linux/libs/uclibc/Glibc_vs_uClibc_Differences.txt


1

I don't know of any portable way to do this. I thought maybe ptrace(), but I can't see how from the manpage. Even if that works, "tracing" the other process in any way is probably unnecessarily invasive For Linux, your suggestion to use fopen("/proc/PID/status", "r") is about as clean and direct as you're going to get. It seems to be what gdb does.



Top 50 recent answers are included