LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2010, 12:12 PM   #1
msaslin
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Rep: Reputation: 0
Calling system calls in C runtime (in the run-time)


I know there is a way to call winapi in runtime in windows. I want to ask how can I call a system call in gcc in runtime (when I don't know what it can be)?
I don't mean syscall that I think is for calling only system calls and not library functions.

Thanks!

Last edited by msaslin; 09-23-2010 at 12:55 PM.
 
Old 09-23-2010, 03:27 PM   #2
msaslin
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Original Poster
Rep: Reputation: 0
what's syscall of linux's equivalence in freebsd? Though it is only for kernel system calls. Calling system calls is with int 80 in asm, how is it for the (static and shared) library functions? How do they work?
 
Old 09-23-2010, 06:48 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

The "moral equivalent" to the Win32 API for Linux is "glibc", the Gnu C runtime library.

Standard library calls like "open()" and "fork()" are thin wrappers around the actual system calls (for example, "asm int 80" for some kernels).

You can learn more about "how it works" here:

http://www.gnu.org/software/libc/man...l#System-Calls

You can get complete source and study it yourself here:

http://www.gnu.org/software/libc/

'Hope that helps
 
Old 09-23-2010, 10:38 PM   #4
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Rep: Reputation: 15
This is the way it was on a linux box about 5 years ago. I don't think it changed much. I would think it should work the same assuming you are using cygwin.

std::string moveAFile = "mv test1 test2";
int check = system(moveAFile.c_str());

Best of luck,

Mike
 
Old 09-24-2010, 03:28 AM   #5
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by msaslin View Post
I know there is a way to call winapi in runtime in windows. I want to ask how can I call a system call in gcc in runtime (when I don't know what it can be)?
I don't mean syscall that I think is for calling only system calls and not library functions.

Thanks!
If you're asking about opening shared libraries dynamically at run-time, then dlopen(), dlsym() and dlclose() might be what you're looking for - they all share the same manpage.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Checking operating system at run time. sanjeebkdeka AIX 1 05-11-2010 01:57 AM
Busy Signal calling asterisk inbound outbound calls AD123 Linux - Server 2 07-28-2009 01:10 PM
calling system calls READ WRITE without any OPEN barunparichha Linux - Kernel 2 06-28-2006 01:11 PM
run process in background using system calls indian Programming 2 08-10-2004 05:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:15 PM.

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