Tagged Questions

The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
0answers
20 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 ...
-1
votes
0answers
13 views

How does the parent select which forked child process to communicate with? [migrated]

I created several child processes from one parent, and I also created bidirectional pipes between each process and the parent. Now the problem is how can I go back and forth between the child ...
0
votes
0answers
49 views

How to fork multiple processes from a same parent´╝č

I am trying to create multiple processes from a same parent, but it always ended up with more processes than expected. I couldn't figure out how to do it and need some help here. I found a piece of ...
2
votes
1answer
66 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 ...
29
votes
4answers
2k 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) ...
1
vote
2answers
49 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 ...
11
votes
3answers
61 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
86 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
100 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
87 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 ...
38
votes
4answers
2k 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 ...
0
votes
2answers
83 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 ...
5
votes
5answers
2k 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
78 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 ...
2
votes
1answer
62 views

How does the kernel know which file descriptor to write data to after fork() in a concurrent server?

Basic concurrent client/server architecture: There's a main loop listening for requests on a port (for example 3000), after accepting the connection the server spawns a child process that ends up ...
5
votes
2answers
256 views

Why do forked processes sometimes appear with brackets [] around their name in ps? [duplicate]

On a Linux system a C process is started on boot, which creates a fork of itself. It is not a kernal process or something. In most cases a ps -ef show both processes as expecxted, but sometimes it ...
12
votes
6answers
906 views

Why does “ls” require a separate process for executing?

Why does ls require a separate process for its execution? I know the reason why commands like cd can't be executed by forking mechanism but is there any harm if ls is executed without forking?
2
votes
1answer
163 views

Which system calls could create a new process?

When executing ps command in my Linux system i see some user processes twice (different PID...). I wonder if they are new processes or threads of the same process. I know some functions in standard C ...
6
votes
3answers
773 views

How to stop Fork Bomb out of memory error - RHEL 6

I set up test VM to test the effect of fork bombs. So I edited the limits.conf as follows for root user: root hard nproc 512 Now I drop a fork bomb like so: :(){ :|:& };: After ...
2
votes
2answers
288 views

How to make processes not die after its parent dies?

I've been messing with forkbombs and noticed that if I just fork() processes repeatedly, killing the initial process will bring down the whole tree. This is not the case for forkbombs written in BASH ...
2
votes
1answer
1k views

child process does not inherit the pending signals from the parent after a fork system call, why?

Could anybody please tell me the reason to why pending signals are not inherited by the child process? On the other hand, the child process inherits the signal handlers and signal mask from the ...
3
votes
2answers
1k views

File descriptor and fork

When a child is forked then it inherits parent's file descriptors, if child closes the file descriptor what will happen ? If child starts writing what shall happen to the file at the parent's end ? ...
12
votes
1answer
908 views

How does a fork bomb work?

WARNING DO NOT ATTEMPT TO RUN THIS ON A PRODUCTION MACHINE In reading the Wikipedia page on the topic I generally follow what's going on with the following code: :(){ :|:& };: excerpt of ...
3
votes
2answers
280 views

When vfork is called is parent process really suspended?

As much as I know when vfork is called child process uses the same address space as that of the parent and any changes made by the child process in parents variables are reflected onto parents ...
3
votes
3answers
203 views

Dmenu Processes Forked by Bash?

I was looking at the output of pstree, and realised that processes that I started using dmenu seem to fork from bash. What is the reasoning behind this? And is there any way I can make dmenu behave ...
5
votes
3answers
630 views

Can I pipe any two processes to each other?

In this page from The Design and Implementation of the 4.4BSD Operating System, it is said that: A major difference between pipes and sockets is that pipes require a common parent process to set ...
1
vote
0answers
257 views

“/sbin/yast: fork: Cannot allocate memory” on openSUSE 10.1

I guess I'll come across as a total newbie for asking this, but I get the above message right after starting an ssh session. The reason I opened the ssh session was that I came across a 500 internal ...
1
vote
1answer
139 views

What rules govern the parent-child relationship of processes launched by shell across a pipe?

#!/bin/ksh # start_service: start the service my_server_executable 2>&1 | my_pipe_following_shell_script & exit 0 After I run the above start_service script from command line, it is ...
3
votes
3answers
1k views

What after exec() in ls command. Is the parent process printing the output to the console or the child?

I have a simple doubt on execution of the command ls. As per my understanding from the research I have done on the internet, I understood the below points. When we type ls command shell interprets ...
5
votes
3answers
2k views

How to track the number of processes and forks per user?

I need to figure out how many forks are done and how many concurrent processes are run by each user over time. It does not look like this information is tracked by my distribution. I know how to ...
2
votes
1answer
165 views

COW and fork - how many frames

Consider process P that owns 10 physical frames. Suppose process P calls fork() and creates a child process Q. How many physical frames does the child initially own, without copy-on-write? 10 How ...
3
votes
1answer
912 views

Program stall under user but runs under root

I am running R job under a normal user john and root. Interestingly, the program stalls under john user but runs quickly under root. Using strace, I found that when john runs the R, the process stalls ...
5
votes
3answers
189 views

Coloring output of forked processes

I have a runscript that starts some processes and sends them to the background mongod & pid_mongo=$! redis-server & pid_redis=$! # etc. All these processes then output concurrently to ...
3
votes
2answers
777 views

What sets a child's STDERR, STDOUT, and STDIN?

If a program runs fork() what sets standard streams STDOUT, STDIN and STDERR?
3
votes
2answers
3k views

How does copy-on-write in fork() handle multiple fork?

According to wikipedia (which could be wrong) When a fork() system call is issued, a copy of all the pages corresponding to the parent process is created, loaded into a separate memory location by ...
4
votes
2answers
1k views

Fork call and recursion

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { fork(); fork(); fork(); puts("hi"); return 0; } This program ...
24
votes
4answers
2k views

What's the difference between running a program as a daemon and forking it into background with '&'?

What are the practical differences from a sysadmin point of view when deploying services on a unix based system?
2
votes
1answer
68 views

How is the inherited file descritor vulnerability dealt with in Unices?

Ulrich Drepper describes a vulnerability in programs that have open file descriptors then they fork() and execve() without lots of very careful locking in place. He also talks about new kernel ...
3
votes
3answers
4k views

Fork bomb on a Mac?

I just learned about a fork bomb, an interesting type of a denial of service attack. Wikipedia (and a few other places) suggest using :(){ :|:& };: on UNIX machines to fork the process an infine ...
10
votes
3answers
4k views

When do you need 'nohup' if you're already forking using '&'?

First this question is related but definitely not the same as this very nice question: Difference between nohup, disown and & I want to understand something: when I do '&', I'm forking ...
1
vote
1answer
2k views

Apache cannot fork: cannot allocate memory

I am running apache on Fedora with mod_perl. The server forks a process to send an email frequently - and the fork exits. Suddenly, I got: Cannot fork: Cannot allocate memory. There was plenty of ...
30
votes
2answers
3k views

Why is the default process creation mechanism fork?

The UNIX system call for process creation, fork(), creates a child process by copying the parent process. My understanding is that this is almost always followed by a call to exec() to replace the ...
4
votes
4answers
6k views

How to totally fork a shell command that is using redirection

I've written quite a few shell scripts over the years (but I'm certainly not a sysadmin) and there's something that always caused me troubles: how can I fork a shell command immune to hangups in the ...
5
votes
1answer
234 views

Why is the following command killing a system?

Anyone understand the following code , running in bash ? :(){ :|:& };: It seems to be a "fork" bomb on Linux.
2
votes
1answer
446 views

There is no bash indicator prompt after a forked process terminates

I am reading the book Advanced Programming in the Unix Environment. There is a test program to test the fork function. It works well in my Ubuntu. But what I confused is that why there is no command ...
2
votes
3answers
1k views

Fork: Negative return value

From the fork(2) man page: RETURN VALUE On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no ...
5
votes
2answers
1k views

Process descendants

I'm trying to build a process container. The container will trigger other programs. For example - a bash script that launches running background tasks with '&' usage. The important feature I'm ...
8
votes
3answers
8k views

Does bash support forking similar to C's fork()?

I have a script that I would like to fork at one point so two copies of the same script are running. For example, I would like the following bash script to exist: echo $$ do_fork() echo $$ If this ...
8
votes
4answers
2k views

Why should a child of a vfork or fork call _exit() instead of exit()?

From the man page of vfork(): vfork() differs from fork() in that the parent is suspended until the child makes a call to execve(2) or _exit(2). The child shares all memory with its ...
9
votes
1answer
3k views

What's the difference between fork() and vfork()?

I would like to understand in detail the difference between fork() and vfork(). I was not able to digest the man page completely. I would also like to clarify one of my colleagues comment "In ...