HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Creating a daemon process
Operating System - HP-UX
1830060
Members
2295
Online
109998
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2002 02:58 PM
09-09-2002 02:58 PM
I am trying to create a daemon process using the setsid() system call. However, the call to setsid() is failing, giving me an error of "Not Owner" (via perror()).
Can anyone point me to the steps for creating a daemon process, using setsid(), invoked from C?
Thanks!
- Scott
Can anyone point me to the steps for creating a daemon process, using setsid(), invoked from C?
Thanks!
- Scott
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2002 03:26 PM
09-09-2002 03:26 PM
Solution
I'm betting that you haven't fork()'ed.
e.g.
if ((pid = fork()) < 0)
{
(void) fprintf(stderr,"Can't fork %d\n",errno);
(void) fflush(stderr);
exit(errno);
}
if (pid != 0) /* parent process */ exit(0);
/* you are now the child */
setsid();
e.g.
if ((pid = fork()) < 0)
{
(void) fprintf(stderr,"Can't fork %d\n",errno);
(void) fflush(stderr);
exit(errno);
}
if (pid != 0) /* parent process */ exit(0);
/* you are now the child */
setsid();
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2002 06:35 PM
09-09-2002 06:35 PM
Re: Creating a daemon process
Right you are! Actually, I was forking, but got the parent & child reversed. Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2002 06:22 AM
09-10-2002 06:22 AM
Re: Creating a daemon process
Let me give you one other option to consider: You might want to write your daemon in Perl. The code is very similar to what you would do in C includin fork() and setsid(). The development is much faster and the code execites almost as fast as C; it's also much more portable. Unless you are doing some extremely specialized tasks, I think you will find that Perl is an extremely good alternative - I've not had to write a daemon in C in over two years but I've probably written 20 or so in Perl.
I've attached an example; don't worry about what this does (it's the server piece of a daemon that handles event synchronization across hosts via socket connections) just look for the fork() and setsid() calls and note that it is very similar to what you do in C.
I've attached an example; don't worry about what this does (it's the server piece of a daemon that handles event synchronization across hosts via socket connections) just look for the fork() and setsid() calls and note that it is very similar to what you do in C.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP