Don’t do this.
FILE *p;
char cmd[32];
p = fopen("/tmp/gdb_cmds", "w");
fprintf(p, "call chdir(\"..\")\ndetach\nquit\n");
fclose(p);
sprintf(cmd, "gdb -p %d -batch -x /tmp/gdb_cmds", getppid());
system(cmd);
It will probably work, though note that Bash’s pwd
command is cached and won’t notice.
More Related Contents:
- 32-bit absolute addresses no longer allowed in x86-64 Linux?
- How can I measure the actual memory usage of an application or process?
- What’s the best way to send a signal to all members of a process group?
- How to prevent a background process from being stopped after closing SSH client in Linux
- What killed my process and why?
- how to install gcc 4.9.2 on RHEL 7.4
- Threads vs Processes in Linux [closed]
- ld cannot find an existing library
- Calling printf in x86_64 using GNU assembler
- Linking OpenSSL libraries to a program
- Maximum number of processes in linux [closed]
- What’s the difference between “statically linked” and “not a dynamic executable” from Linux ldd?
- Linux clock_gettime(CLOCK_MONOTONIC) strange non-monotonic behavior
- Can _start be the thumb function?
- How to write data to existing process’s STDIN from external process?
- How to change the default GCC compiler in Ubuntu?
- Linux Script to check if process is running and act on the result
- How to avoid STT_GNU_IFUNC symbols in your binary?
- How can I select a static library to be linked while ARM cross compiling?
- What is the ‘soname’ option for building shared libraries for?
- Number of executed Instructions different for Hello World program Nasm Assembly and C
- Programmatically get parent pid of another process?
- Is there a way to get gcc to output raw binary?
- Trying to understand gcc’s complicated stack-alignment at the top of main that copies the return address
- How do I get the path of a process in Unix / Linux?
- How to get the start time of a long-running Linux process?
- Do I need -D_REENTRANT with -pthreads?
- undefined reference to symbol even when nm indicates that this symbol is present in the shared library
- How do I recover a semaphore when the process that decremented it to zero crashes?
- Responsibility of stack alignment in 32-bit x86 assembly