Creating System Call, need PID of caller


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Creating System Call, need PID of caller
# 1  
Old 06-03-2009
Creating System Call, need PID of caller

Hey

I am creating a new system call that needs to know the PID of the calling process. I am new to coding in the kernel, so I don't know if this is possible... Any help would be nice.

Thanks!
Hapatchi
# 2  
Old 06-03-2009
Perhaps try using getppid()or getpid()
# 3  
Old 06-03-2009
Does that work from the kernel? I thought that because the process that made the call was technically no longer executing its code that this would not be valid.

If this is not the case though, than thanks!
I'll give it a shot.
Hapatchi

EDIT:
I can't seem to get either one to work. Mainly, this is because I can't seem to include <sys/types.h>. It can be included from non-kernel files, but the kernel doesn't like having it... Ideas?

Last edited by Hapatchi; 06-03-2009 at 09:19 PM.. Reason: I tried it
# 4  
Old 06-04-2009
You can use the current macro to retrieve it from the task struct i.e.
Code:
printk("Current PID is  %d\n", current->pid);

# 5  
Old 06-04-2009
Aha! You, good sir, are a genius.

Thanks a bunch
Hapatchi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Creating a .profile, displaying system variables, and creating an alias

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here is what I am supposed to do, word for word from my assignment page: 1. Create/modify and print a... (2 Replies)
Discussion started by: Jagst3r21
2 Replies

2. Shell Programming and Scripting

system call

Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035> poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies

3. Programming

need help with system call

hi everyone i wrote a system call and compiled the kernel succesfully... my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c) the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h my problem is... (2 Replies)
Discussion started by: demis87
2 Replies

4. Programming

system call

I have a cgi script which is called after certain time interval, which has this: system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'"); During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies

5. Programming

C:system call

Hi I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process. I'm reading that i should use the tms struct: clock_t times(struct tms *buf); struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies

6. Shell Programming and Scripting

system call

Hi, How to write a system calls in a script ? > cd $HOME > ls -ltr thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies

7. Shell Programming and Scripting

How to find pid of PS which executed by perl system function

hello All, I need to invoke by perl script some program/command and monitor it for 5 minutes . In case it still running for more then 5 min I need to send a signal which will stop it. I implemeted this as shown below by using eval & alarm and I'd like to know if there is a better way to... (1 Reply)
Discussion started by: Alalush
1 Replies

8. UNIX for Advanced & Expert Users

To get PID of a command passed to a secondary system

Hi Reqmt: I am working on Sys 1 and passes a command to Sys2 using a utility which has ssh coded in it. Is there any way to get the process id of the command in Sys 2 from my Sys1 ? Note: The utility is not editable, so you cannot get it through it and I am not logged in in Sys2. Thanks... (2 Replies)
Discussion started by: anu_math9
2 Replies

9. UNIX for Dummies Questions & Answers

UNIX System Call for creating process

Hell Sir, This is chanikya Is there any System call which behaves just like fork but i dont want to return back two times to the calling func. In the following ex iam creating a child process in the called func but the ex prints two times IN MAIN. ex :- calling() { fork(); } ... (2 Replies)
Discussion started by: chanikya
2 Replies

10. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies
Login or Register to Ask a Question