Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 26th, 2005, 4:06 AM   #1
lucifer
Programmer
 
lucifer's Avatar
 
Join Date: Oct 2005
Posts: 86
Rep Power: 10 lucifer is on a distinguished road
what is getpid() function

hi,
i am writing a http server programme and have an old code from a friend which uses getpid in error messages so can any body tell me what is the equivalent of this function in windows.
 case ERROR: (void)sprintf(logbuffer,"ERROR: %s:%s Errno=%d exiting 
           pid=%d",s1, s2, errno,getpid()); break;
lucifer is offline   Reply With Quote
Old Nov 26th, 2005, 4:23 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,329
Rep Power: 11 grumpy will become famous soon enough
getpid() under unix gets an integer that identifies the current process (i.e. the process id).

In the win32 API, look for the function GetCurrentProcessId().
grumpy is offline   Reply With Quote
Old Nov 26th, 2005, 6:24 AM   #3
lucifer
Programmer
 
lucifer's Avatar
 
Join Date: Oct 2005
Posts: 86
Rep Power: 10 lucifer is on a distinguished road
thanks can u also tell me about these functions equivalent in windows


getenv()
A simple function for returning the shell variable values. If you set a Korn shell variable $ export ABC=123, then the getenv("ABC") function would return a pointer to a null terminated string containing 123.
chdir()
Changes directory.
fork()
Starts a child process. In the parent, it returns the process id (PID) of the child, and in the child, it returns zero.
setpgrp()
Sets the process group. The effect is for this process to break away from the other processes started by this user so it will not be affected by what happens to the users (like logging off).
signal()
Decides what happens when software interrupts arrive for the process. Within the nweb.c code, the main server wants to ignore the death of a child signal. Without this, the main server process would have to run the wait system call for each child process, or they would be forever stuck in the "zombie" state waiting for the parent to call the wait() function. Eventually, there would be too many zombie processes and the user's environment would hang, as they could not create further processes
lucifer is offline   Reply With Quote
Old Nov 26th, 2005, 6:35 AM   #4
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 10 Polyphemus_ is on a distinguished road
Just search in the msdn library for the descriptions, you will find enough.

Another function in windows equal to getpid() is _getpid(), i believe.
Polyphemus_ is offline   Reply With Quote
Old Nov 26th, 2005, 7:52 AM   #5
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,329
Rep Power: 11 grumpy will become famous soon enough
The win32 API help file will also help out.

The way windows and unix handle processes is quite different. fork() [which essentially creates a copy of the current process and state] is not supported under windows. Similarly with setpgrp(), as windows does not rely on the notion of program groups. You will need to work out a way of achieving the behaviour you intend.

signal() is a standard C function, but it's behaviour under unix is a bit different than under windows (eg there is no linkage between that function and anything like zombie processes under unix).
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:38 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC