The tag has no usage guidance.

learn more… | top users | synonyms

1
vote
1answer
34 views

wrapper script: fork: retry: No child processes

"myapplication" needs some setup or clean up done, so I use the following wrapper script: #!/bin/bash echo "Do important set up stuff" myapplication echo "Clean up" and put it in my path, named "...
13
votes
4answers
716 views

How to pass a password to a child process?

Passing a password on command line (to a child process started from my program) is known to be insecure (because it can be seen even by other users with ps command). Is it OK to pass it as an ...
1
vote
0answers
34 views

Theoric: How to kill a forever forking process?

Let's say you have a process that forks every time it has the chance. It launches itself in niceness -20, so it forks faster than you can kill it. Also, it remembers its childrens and it parents, so ...
10
votes
1answer
290 views

How does ksh93 avoid forks in command substitution

Given cmd='fun(){ echo "$@"; }; fun $(fun $(fun hi))' shells tend to need to make 2 forks to make it happen strace-f(){ strace -f "$@" 2>&1; }; for sh in dash bash zsh ksh; do ...
2
votes
1answer
57 views

Putting subshell in background vs putting command in background

I have two bash scripts that try to check hosts that are up: Script 1: #!/bin/bash for ip in {1..254}; do ping -c 1 192.168.1.$ip | grep "bytes from" | cut -d" " -f 4 | cut -d ":" -f 1 & ...
-1
votes
2answers
78 views

Does the Ubuntu Linux 16.04 daemon function execute a double fork? [closed]

Does the Ubuntu Linux 16.04 daemon function execute a double fork? If so, why is a double fork necessary?
11
votes
1answer
216 views

Why do these bash fork bombs work differently and what is the significance of & in it?

I get how a normal fork bomb works, but I don't really understand why the & at the end of the common bash fork bomb is required and why these scripts behave differently: :(){ (:) | (:) }; : and ...
0
votes
2answers
66 views

Daemon to: receive messages -> run background command -> manage number of tasks running simulatenously?

Looking for a unix program that runs in the background (daemon), that: can receive arbitrary (JSON) messages. On receiving a message, run a specified command. Has option for limiting number of ...
0
votes
1answer
55 views

What will happen if I run a “fork bomb” on my machine?

What will happen after using the fork bomb command?
0
votes
2answers
50 views

Parent process always printing output after child

Consider the following code running under Solaris 11.3: int main(void) { pid_t pid = fork(); if (pid > 0) { printf("[%ld]: Writing from parent process\n", getpid()); } if (...
0
votes
0answers
78 views

What differences are between running a command in shell with and without `bash -c`?

What is the difference of running a command directly in a bash shell, and run it as bash -c <command> in a bash shell? The purpose of my question is that I would like to know how a command is ...
0
votes
0answers
66 views

Compare running a command directly and in background

In Ubuntu, I run date in an interactive bash shell whose pid is 6913, and at the same time, trace the bash shell from another interactive bash shell by strace. By using tracing, I would like to ...
1
vote
1answer
110 views

How to understand the output of tracing running an external command in bash?

In Ubuntu, I run date directly in an interactive bash shell whose pid is 6913. $ date Wed Mar 2 23:57:44 EST 2016 At the same time, I trace the bash shell 6913 from another interactive bash shell ...
1
vote
0answers
79 views

How to understand the output of tracing running an external command in background via strace

In Ubuntu, I run date & in an interactive bash shell whose pid is 6913, and at the same time, trace the bash shell from another interactive bash shell by strace. The output of tracing the first ...
0
votes
2answers
97 views

Why doesn't strace report that the parent shell fork() a child process before execve() a command?

strace runs a specified command until it exits. It intercepts and records the system calls which are called by a process and the signals which are received by a process. When running an external ...
1
vote
1answer
48 views

Process Flag 1: Forked but didn't exec (use case?)

In the man page for ps, it lists process flag 1 as "process forked but didn't exec". What would be a common use case/situation for a process to be in this state?
1
vote
3answers
103 views

On `fork`, children processes, and “subshells”

This post is basically a follow-up to an earlier question of mine. From the answer to that question I realized that not only I don't quite understand the whole concept of a "subshell", but more ...
0
votes
1answer
398 views

Process tree using fork() [closed]

I am given the task of creating this process tree in C using fork, if and else: |_____1___ |___2__ | |_4_ | |_3_ | | | | | Or as a pstree like drawing: p(0)─┬─p(1)───p(3) ├─p(2) ...
3
votes
1answer
352 views

Get output of `posix_spawn`

So I can run a process in Unix / Linux using POSIX, but is there some way I can store / redirect both the STDOUT and STDERR of the process to a file? The spawn.h header contains a deceleration of ...
1
vote
1answer
97 views

(SOS) -bash: fork: Not enough space on every command

I'm running SmartOS in a SmartOS Zone, and now any bash command return me -bash: fork: Not enough space Works only ulimit How to fix it?
3
votes
1answer
75 views

GDB hangs forever on Solaris

GDB seems to hang everytime when I try run command from gdb prompt. When I ran ps, there are two gdb processes that have been spawned and pstack reveals the following - 15:47:02:/home/stufs1/...
2
votes
1answer
314 views

How can two identical virtual addresses point to different physical addresses?

Following a fork() call in Linux, two processes (one being a child of the other) will share allocated heap memory. These allocated pages are marked COW (copy-on-write) and will remain shared until ...
2
votes
1answer
333 views

Why does a “child” process finish before its parent?

This is the code example given: # include <stdio.h> # include <unistd.h> void main() { static char *mesg[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; int display(char *)...
1
vote
1answer
140 views

fork() and exec() confusion

As when we do fork on current process, our process as parent process generates child process with same characteristics but different process IDs. So after that, when we do exec() in our child process, ...
2
votes
3answers
258 views

How to find out the process(es) that forks a lot?

Recently I got an load-too-high issue on our server. I watched top for like half an hour to find out that it was Nagios that forked a lot of short-lived processes. After bouncing Nagios, everything ...
1
vote
1answer
468 views

Launch Spark in Foreground via Supervisor

We have a spark cluster that launches via supervisor. Excerpts: /etc/supervisor/conf.d/spark_master.conf: command=./sbin/start-master.sh directory=/opt/spark-1.4.1 /etc/supervisor/conf.d/...
3
votes
4answers
76 views

Who forks the processes of piped commands in the shell?

Consider this command in the shell : ls|less Now we know that ls and less are run as two different processes. We know that the shell forks and creates a child process which load the ls program using ...
0
votes
1answer
204 views

Why signal function is not able to call my signal Handler? [closed]

Here I have written a signal handler function named as handler Correspondingly this handler is registered to kernel using the signal function that will be invoked when SIGCHLD signal is generated by ...
-5
votes
1answer
80 views

How fork() is executed in logical operator? How many times “Hi” is printed ? How? [closed]

#include <stdio.h> #include <unistd.h> int main() { (fork() && fork()) || (fork() && fork()); printf("Hi...\n"); return 0; }
1
vote
1answer
145 views

Why does this bash fork bomb not work on my RHEL VM?

I'm running a RHEL 6.5 VM in a VMware ESXi environment and accessing it through the vSphere Web Client virtual console (in my browser). I wanted to crash this machine on purpose and executed :(){ :|...
4
votes
1answer
614 views

what does it mean 'fork()' will copy address space of original process

I'm studying 'operation system concepts' on my own and I'm studying the chp3. process part. There is an example where the 'fork()' function is called and depending of the returned pid value like the ...
11
votes
3answers
916 views

When a process forks is its virtual or resident memory copied?

The standard way of making new processes in Linux is that the memory footprint of the parent process is copied and that becomes the environment of the child process until execv is called. What memory ...
5
votes
2answers
12k views

fork: retry: Resource temporarily unavailable

While I am connecting to my server I get, -bash: fork: retry: Resource temporarily unavailable -bash: fork: retry: Resource temporarily unavailable -bash: fork: retry: Resource temporarily ...
18
votes
3answers
4k views

Fork vs Clone on 2.6 Kernel Linux

I have some confusion regarding fork and clone. I have seen that: fork is for processes and clone is for threads fork just calls clone, clone is used for all processes and threads Are either of ...
2
votes
4answers
492 views

What is an open file description?

When you fork a process, the child inherits its parent's file descriptors. I understand that when this happens, the child receives a copy of the parent's file descriptor table with the pointers in ...
11
votes
4answers
5k views

How do fork and exec work?

I don't have much experience, just trying to get involved into the processes how do they interpret to hardware from user level. So when a command is fired from a shell, fork() inherits a child ...
3
votes
1answer
3k views

fork() and how signals are delivered to processes

I program that I wrote in C fork()'s off a child process. Neither process will terminate. If I launch the program from the command line and press control-c which process(es) will receive the interrupt ...
1
vote
1answer
181 views

When parent, child and grandchild processes share a page how does copy-on-write work?

If the child tries to write, it gets a new copy of the page (which is no longer write protected), does the grandchild point to that new page or the old one (which the parent holds)?
2
votes
1answer
431 views

SSH fork kills connection

I am using a linux script which has the task of forwarding control of the system to remote support. In this script one of the commands is a ssh port forward command that will forward the port of the ...
2
votes
1answer
521 views

What are the semantics of getting a EADDRINUSE when no listening socket is bound, but connections are open

Consider a parent process which completes a socket/bind/accept, and will fork children with that socket open for them to communicate with, while the parent continues accepting connections. That parent ...
35
votes
4answers
6k views

Is there any UNIX variant on which a child process dies with its parent?

I have been studying the Linux kernel behaviour for quite some time now, and it's always been clear to me that: When a process dies, all its children are given back to the init process (PID 1) ...
2
votes
2answers
148 views

How does bash pass user groups to a child?

It is well-known that if I add myself to a new group, that change will not be reflected until I log out and back in: $ sudo adduser me newgroup $ groups me sudo $ groups me me sudo newgroup $ This ...
16
votes
3answers
4k views

Does fork() immediately copy the entire process heap in Linux?

A fork() system call clones a child process from the running process. The two processes are identical except for their PID. Naturally, if the processes are just reading from their heaps rather than ...
1
vote
1answer
126 views

What is the exact function of this malicious bash one-liner?

I can't figure out what this is trying to do. The part between backticks looks like a plain old forkbomb, but the base64 doesn't seem to decode to anything sensible. Can you help? Don't run it, ...
2
votes
1answer
737 views

How does bash actually change stdin/stdout/stderr when using redirection/piping

Unfortunately I've had no luck figuring this out, as everything I find is just on the syntax of redirection, or shallow information about how redirection works. What I want to know is how bash ...
0
votes
3answers
273 views

How to fork a “cat” command?

This is my bash script. #!/bin/bash oo="`cat /etc/httpd/conf/httpd.conf`"; cat > /a.txt << EOF $oo EOF it simply reads /etc/httpd/conf/httpd.conf and writes it to /a.txt, the problem has ...
65
votes
6answers
17k views

Why do we need to fork to create new processes?

In Unix whenever we want to create a new process, we fork the current process, creating a new child process which is exactly the same as the parent process; then we do an exec system call to replace ...
1
vote
2answers
843 views

Bind one process to multiple ports?

I have a socket server running and listening for incoming connections on a non-admin port (i.e. > 1024). I would also like for this process to be able to handle another type of connection on a ...
8
votes
5answers
8k views

Threads vs (Forked) Processes

Linux applications generally fork then exec (with execve() ), but Java applications, and certain Apache MPMs use threading. If forking, uses the fork + exec to spawn a process, what is the high level ...
1
vote
2answers
250 views

How to limit the number of process that a user can create?

I think I have a program that creates countless forks of itself (not intentionally, I hope). I like to test this but I can't kill the machine, so how could I limit the number of process to execute ...