LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2020, 09:35 PM   #1
Victor43
Member
 
Registered: May 2020
Posts: 46

Rep: Reputation: Disabled
How to find out what system calls are being made ?


How to determine what if any system calls are being made by the following C functions
1) execave
2) fork()

I understand that for the fork function call Clone is called but how can I check this and confirm myself?

Thanks
 
Old 08-10-2020, 12:08 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I understand that fork and clone are two different system calls. Read their respective man pages for confirmation.

To see the system calls made by a specific process, use strace.
To see system calls made globally, use the audit subsystem. For an off-the-cuff audit, see the auditctl command.
 
1 members found this post helpful.
Old 08-10-2020, 01:27 PM   #3
Victor43
Member
 
Registered: May 2020
Posts: 46

Original Poster
Rep: Reputation: Disabled
Thank you berndbausch. Is it possible to run gdb set a break point on fork() and then step into fork() to see the code behind fork() in order to see if clone() is called ? I hope this makes sense and is clear.
 
Old 08-10-2020, 06:02 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
This is the second (very) similar thread. I'm still not sure what you are asking - or if you know yourself what you are asking.

If you really have to know, go look at the source. Else the kernel now has quite extensive tracing that allows you to dynamically step into kernel-space functions as they are running. Perhaps have a look at sysdig - it does all the setup work for you and has tools that will do what you want. Has a learning curve, but far less than learning the underlying tracing infrastructure itself.
 
1 members found this post helpful.
Old 08-10-2020, 06:04 PM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Perhaps, but if you see fork in strace or audit, you know that it is a system call.

Actually, it is sufficient to consult the system call list.
 
1 members found this post helpful.
Old 08-12-2020, 06:37 PM   #6
Victor43
Member
 
Registered: May 2020
Posts: 46

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
This is the second (very) similar thread. I'm still not sure what you are asking - or if you know yourself what you are asking.

If you really have to know, go look at the source. Else the kernel now has quite extensive tracing that allows you to dynamically step into kernel-space functions as they are running. Perhaps have a look at sysdig - it does all the setup work for you and has tools that will do what you want. Has a learning curve, but far less than learning the underlying tracing infrastructure itself.
Thank you for the post. This is what I am trying to do is to find out whether fork() calls the clone() system call.
 
Old 08-12-2020, 07:51 PM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by syg00 View Post
If you really have to know, go look at the source.
Quote:
Originally Posted by Victor43 View Post
Thank you for the post. This is what I am trying to do is to find out whether fork() calls the clone() system call.
You're asking a question where you've already received the pathway to the answer.

The truth is that fork() defines system calls, and I feel you'd see this by inspecting the code.

I applaud you for asking deep questions about the kernel implementation, however I do not feel that you can only go by Q&A here, you really do need to study the code for the various kernel components you are asking about.

At that point, it becomes the question of, "are you interested in becoming a deep core kernel developer, or not?", and that's a question you may have a quick response to, "YES!" with excitement, or you may not know. But once you start reading some code, you may find, as I very much have found myself, that a lot of the code in there is not stuff I wish to play around with much.

It's not as simple as running GDB, you can run GDB on code you have, but it won't do you much good going into normal C libraries, because those are binaries, and the same applies to the kernel, you should have the matching kernel source on your system, but what is running has been optimized and has had the symbols removed. So like any debugger when you go into a library or system call, you find yourself at the assembly level, no symbols, and you can single step, but you have no idea what or where it is, especially well enough to discern much.

I've actually done one form of kernel development. Built in variables, and printk's. I asked at the time, "Hey! We probably use KDB here, ... right?" I mean, I was in a kernel development shop. And everybody looked at me askance, meaning, "Knock yourself out cowboy."

And so I gave it a try, but could not get it to work for me, so I mimicked my peers. I'll admit, that I've "configured and compiled" many custom kernels and done some minor code modifications, mostly to drivers, but I'm no kernel developer.

That said, when I've had deep core issues where I needed to modify something in the kernel, I've found what I needed by looking at the code and writing modifications, just not written entire system calls from scratch.

Same point is if I had a burning question about some kernel code, I'd read that code.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how does java calls the system calls which are written in c babu198649 Linux - General 3 12-05-2011 03:40 AM
a script calls another script which calls "bash" inside lordofring Linux - Software 10 03-18-2010 09:59 AM
Find out how much dater is being used after a doing a find +500 ibizatunes Programming 1 02-24-2010 06:07 AM
printing out names of all system calls ananthbv Programming 5 08-30-2005 11:56 AM
can u find out the I.P address a yahoo i.d was made at??? peterpeter General 3 08-06-2003 07:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration