Skip to main content

Questions tagged [exec]

The exec() family of functions replaces the current process image with a new process image, retaining the pid and pipes of the old process. This tag is also used for the shell built-in which can be used to replace the current shell with a program or various redirection-related stuff.

4votes
2answers
2kviews

'exec fish' at the very bottom of my '.zshrc' - is it possible to bypass it?

I prefer to use the fish shell on macOS most of the time, but refrain to make it the login shell, because I think sometimes it may cause problems. So, I simply added exec fish at the very bottom of my ...
jsx97's user avatar
  • 1,347
2votes
0answers
43views

In the context of {ARG_MAX}, how robust is `find . -exec sh -c 'exec tool "$@" extra-arg' find-sh {} +`?

Suppose I want to do this: find . -exec tool {} extra-arg + It doesn't work and I know why: -exec … {} + does not allow extra-arg(s) between {} and +. So be it. It seems I can inject the extra-arg by ...
Kamil Maciorowski's user avatar
2votes
1answer
91views

Why does exec in bash script run by cron not preserve $PATH?

I have the following cron job setup on Debian 12: /etc/cron.d/jonathan-test: SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin * * * * * jonathan /home/jonathan/test1....
jnrbsn's user avatar
0votes
1answer
40views

Are reads of /proc/pid/environ atomic in Linux 6.x (e.g: 6.1.99)?

When a process execs, looking at kernel code for environ_read(), it seems that if the mm_struct doesn't yet exist / is null or the env_end member of that mm_struct is null, environ_read() will return ...
Gregg Leventhal's user avatar
0votes
0answers
78views

Using systemd + docker exec to manage processes within a single container

As of today, I have many systemd services where each of them runs a command using docker run. The same docker is used for all services. I've noticed that each container that runs, takes about 0.7% of ...
Omer's user avatar
  • 101
0votes
0answers
69views

Understanding AFL behaviour for fork and execv; Why `/proc/<pid>/maps` does not show the loaded binary

TL;DR Why process map in /proc/<pid>/maps does not show where the executed binary is loaded? I am trying to do some post-mortem analysis of the fuzzed program once it finishes. Basically what I ...
sorin the turtle's user avatar
2votes
1answer
211views

How to pass a parameter to a command that's being executed by exec in bash?

I'm trying to start a subprocess with a unique process name from a bash script. This works: bash -c "exec -a MyUniqueProcessName './start_service' &" but my problem is that I want to ...
Adam Arold's user avatar
4votes
1answer
207views

POSIX Shell: `exec` with changed arg0

I want to exec a program and control it's arguments including arg0 and environment. Using C I could go for execve. Can I do this in POSIX shell?
Patrick Böker's user avatar
0votes
1answer
248views

How to perform strace on shell without changing your current shell?

I use strace to trace the behavior of a bash process. The purpose is to find out the order bash loads its configuration files. I am running the following command under zsh: strace -e openat bash ...
Visrut's user avatar
16votes
1answer
1kviews

Is the behavior of bash -c "<single command>" documented?

It's quite known that when running bash -c "COMMAND" (at least in the common versions in Linux) when there's a single command without any metacharacter (except for space, tab or newline), ...
aviro's user avatar
  • 6,772
0votes
2answers
85views

Creating an option for 'exec > >(tee -ia $OUT)' to skip stdout

I'm trying to modify a script that uses the following: # first portion of script # ... exec > >(tee -ia $OUT) # ... # second portion of script The problem I have with this script is that it ...
Seamus's user avatar
  • 3,727
0votes
1answer
72views

How to execute a subshell directly

I have this: timeout 25 bash -c ' for i in {1..9}; do if read line < "$my_fifo"; then if test "$line" != "0"; then exit 0; ...
Alexander Mills's user avatar
3votes
1answer
255views

How to stop redirection via exec

I want to redirect some output of a script to a file. REDIRECT_FILE="foo.txt" echo to console # starting redirect exec > $REDIRECT_FILE echo to file echo ... echo ... # stop redirect ...
Andy A.'s user avatar
0votes
0answers
69views

How to regain script interactivity when `... | bash` best practices?

Let's say we have a simple script named question: #!/bin/bash read -rp "What's your name?" ans echo "Your name is $ans" Let's use cat for our example cat question | bash We ...
punkbit's user avatar
0votes
1answer
97views

How is this exec command supposed to work in this context?

I'm working through a textbook on UNIX system administration. Chapter 3 of "Unix Third Edition" by a Syed Mansoor. Chapter 13 has the following example of exec usage which is straightforward ...
Anthony De Vellis's user avatar

153050per page
close