kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* fork
@ 2016-04-18  6:48 Nitin Varyani
  2016-04-18  7:12 ` fork Alex Wilson
  2016-04-18  8:18 ` fork Cihangir Akturk
  0 siblings, 2 replies; 5+ messages in thread
From: Nitin Varyani @ 2016-04-18  6:48 UTC (permalink / raw)
  To: kernelnewbies

Linux kernel development by Robert Love describes the fork process as

fork() -> clone() -> do_fork() -> copy_process()

I am unable to find the clone() system call in linux 3.13.
Can someone explain the proper flow of fork() system call initiated by the
user?

Where can I find the libc implementation for fork()? I want the code of all
the functions involved in fork.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160418/248505f9/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* fork
  2016-04-18  6:48 fork Nitin Varyani
@ 2016-04-18  7:12 ` Alex Wilson
  2016-04-18  8:18 ` fork Cihangir Akturk
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Wilson @ 2016-04-18  7:12 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Apr 18, 2016 at 12:48 AM, Nitin Varyani
<varyani.nitin1@gmail.com> wrote:
>
>
> Linux kernel development by Robert Love describes the fork process as
>
> fork() -> clone() -> do_fork() -> copy_process()
>
> I am unable to find the clone() system call in linux 3.13.
> Can someone explain the proper flow of fork() system call initiated by the user?
>
> Where can I find the libc implementation for fork()? I want the code of all the functions involved in fork.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

I believe the fork and clone syscalls are found at /kernel/fork.c
under 3.13. (see link below)
They're wrapped in the nice SYSCALL_DEFINE# macros and all seem to
call do_fork().

http://lxr.free-electrons.com/source/kernel/fork.c?v=3.13#L1641

Can't really help you on the libc part, and you would need to specify
which libc implementation you're interested in.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* fork
  2016-04-18  6:48 fork Nitin Varyani
  2016-04-18  7:12 ` fork Alex Wilson
@ 2016-04-18  8:18 ` Cihangir Akturk
  1 sibling, 0 replies; 5+ messages in thread
From: Cihangir Akturk @ 2016-04-18  8:18 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Apr 18, 2016 at 12:18:00PM +0530, Nitin Varyani wrote:
> Linux kernel development by Robert Love describes the fork process as
> 
> fork() -> clone() -> do_fork() -> copy_process()
> 
> I am unable to find the clone() system call in linux 3.13.
> Can someone explain the proper flow of fork() system call initiated by the
> user?
> 
> Where can I find the libc implementation for fork()? I want the code of all
> the functions involved in fork.

There are a couple of libc implemetations out there, say musl,
dietlibc, uClibc and so on. But If you mean GNU libc aka. glibc
then this is what you are looking for:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/nptl/fork.c;h=1a68cbd6476b3268b5b7ac09ae60c35ce7069219;hb=HEAD#l47

__libc_fork() calls clone() syscall internally using a bit of
assembler magic.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fork
  2020-01-09 10:35 Fork Christophe DUMONT
@ 2020-01-09 10:47 ` Valentin Vidić
  0 siblings, 0 replies; 5+ messages in thread
From: Valentin Vidić @ 2020-01-09 10:47 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Jan 09, 2020 at 10:35:16AM +0000, Christophe DUMONT wrote:
> How does the kernel knows when a process calls the fork function that
> he has the rights to create a new process ?

Not sure what you mean by rights, but in copy_process you can
see different checks and errors that can happen when creating
a new process:

https://elixir.bootlin.com/linux/latest/source/kernel/fork.c#L1760

-- 
Valentin

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fork
@ 2020-01-09 10:35 Christophe DUMONT
  2020-01-09 10:47 ` Fork Valentin Vidić
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe DUMONT @ 2020-01-09 10:35 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 129 bytes --]

Hello,

How does the kernel knows when a process calls the fork function that he has the rights to create a new process ?



[-- Attachment #1.2: Type: text/html, Size: 2088 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-09 10:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-18  6:48 fork Nitin Varyani
2016-04-18  7:12 ` fork Alex Wilson
2016-04-18  8:18 ` fork Cihangir Akturk
2020-01-09 10:35 Fork Christophe DUMONT
2020-01-09 10:47 ` Fork Valentin Vidić

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).