The tag has no wiki summary.

learn more… | top users | synonyms

-5
votes
1answer
33 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
36 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 :(){ ...
3
votes
1answer
38 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 ...
7
votes
3answers
416 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 (parent) the parent process is copied and that becomes the environment of the child process until execv is called. ...
1
vote
1answer
191 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 ...
16
votes
3answers
742 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
117 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 ...
9
votes
4answers
1k 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 ...
1
vote
1answer
188 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
90 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
143 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
278 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 ...
32
votes
4answers
3k 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
82 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 ...
14
votes
3answers
844 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
94 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
303 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
162 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 ...
50
votes
4answers
6k 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
414 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
5k 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
101 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
95 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
503 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
2k 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
364 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 ...
7
votes
3answers
2k 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
620 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
2k 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
3k 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 ? ...
13
votes
1answer
1k 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
463 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
254 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 ...
6
votes
3answers
1k 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
381 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
188 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
2k 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
3k 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 ...
3
votes
1answer
192 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
2k 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
232 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
1k views

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

If a program runs fork() what sets standard streams STDOUT, STDIN and STDERR?
6
votes
2answers
5k 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
2k 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 ...
26
votes
4answers
4k 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?
3
votes
1answer
76 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 ...
4
votes
3answers
6k 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 ...
13
votes
3answers
6k 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
3k 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 ...
32
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 ...