Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Elegant

Name: Anonymous 2008-05-19 11:22

An elegant solution for this:

    /*
    note: the double-fork construct avoids zombie processes
    and keeps the code clean from stupid signal handlers.
    */

    ...
    if(fork() == 0) {
        if(fork() == 0) {
            ..
            execl(pp, pp, (char*) NULL);
            _exit(0);
        }
        _exit(0);
    }
    wait(NULL);
    ..

Thanks

Name: Anonymous 2008-05-19 11:24

You're welcome.

Name: Anonymous 2008-05-19 11:27

>>1
Looks elegant to me.

Name: Anonymous 2008-05-19 11:33

>>3
Two forks is elegant? I only need one syscall for creat one process.

Name: Anonymous 2008-05-19 11:37

>>4
then you clearly don't understand the problem addressed in the comment.
Also, do not use _exit(). Use _Exit or exit.

Name: Anonymous 2008-05-19 11:58

>>5
I understand the problem, I need that at PPID of new process /= PID of my process (<=> new parent process = init). I don't know if exist better solution...


And the function _Exit() is equivalent to _exit(), but _exit is in unistd.h and _Exit in stdlib, and I can't use stdlib.h for third reasons...

Name: Anonymous 2008-05-19 12:57

>>6
_Exit() is ISO C, _exit is not. They also behave differently. Use _Exit().
If you cannot include <stdlib.h> just include the prototype in scope:
void _Exit(int);

Name: Anonymous 2008-05-19 14:52

>>7
Yes, _exit() is not a ISO C, _exit() is a unix syscall...
Then, why I can't use _exit()?

Name: Anonymous 2008-05-19 14:56

>>8
Because your face.

Name: Anonymous 2008-05-19 17:04

>>7
Surprise, fork() isn't ISO either. There's absolutely no point in using _Exit() here. And exit() would be just wrong.

Name: Anonymous 2008-05-19 20:30

just ignore SIGCHLD.

Name: Anonymous 2008-05-19 21:40

oh shi- unix. I can't fucking understand this unix shit. IT'S NO POSIX GUISE! IT CANT BE

Name: Anonymous 2008-05-20 8:42

What would this look like on Windows 98? It's what I'm running.

Name: Anonymous 2008-05-20 8:48

>>13
Hahahahahahahaha. Enjoy your Windows API.

Name: Anonymous 2008-05-20 9:02

>>11
Is not only SIGCHLD...

Name: Anonymous 2008-05-20 9:32

>>14
I will, along with my job.

Name: Anonymous 2008-05-20 10:17

>>16
Haha enjoy your job

Name: Anonymous 2008-05-20 10:33

>>17
I will, along with my Windows API.

Name: Anonymous 2008-05-20 10:36

>>15
if you ignore SIGCHLD you won't get zombie processes.

Name: Anonymous 2008-05-20 14:42

>>19
I'll just use SIGCRWBR

Name: Anonymous 2008-05-20 14:48


 AN ELAGANT SOLUTION FOR THIS
/*
 NOTE TEH DOUBLE-FORK CONSTRUCT AVOIDS ZOMBEI PROCESES
 AND KEPS TEH CODE CLEAN FROM STUPID SIGNAL HANDL3RS
!11!!1!1 OMG */
 .
!!!11!!11!!1!1!11111!! OMG WTF IF(FORK() = 0) {
 IF(FORK() = 0) {
 .
!!1111!!!!!!1!! WTF AXECL(P P (CHAR*) NUL)
 _EXIT(0)
 }
 _3XIT(0)
 }
 WATE(NUL)

 .
!!!1!11!!1!1111 OMG LOL THX

Name: Anonymous 2008-05-20 15:13

>>19
but the child process can send signals to the parent.

Name: Anonymous 2008-05-20 20:54

(avoid-zombie-processes NULL)

Name: Anonymous 2008-05-21 3:06

(avoid-zomie-processes NIL)
* fixed it

Name: Anonymous 2008-05-21 5:50

>>22
double fork faggotry won't change that.

Name: Anonymous 2008-05-21 11:04

>>25
but the parent will be init and not my process.

Name: Anonymous 2008-05-21 12:58

>>26
but the child process can still send signals to your process.

Name: Anonymous 2008-05-21 15:57

>>27
but if the child process haxes inits anus is it incest

Name: Anonymous 2008-05-21 16:06

>>28
Good observation. Maybe /prog/ is still good?

Name: Anonymous 2008-05-21 16:27

>>29
The board you are referring to may be still good, but your observation is not relevant to the topic or this board itself.

Speaking of which, in my opinion, the referred comment doesn't make this board better or worse. Which most of you may express directly with kind words such as "sage"

Name: Anonymous 2008-05-22 7:26

Add setsid(), and you have just reinvented daemonize()

Name: Anonymous 2008-05-22 7:49

Name: Trollbot9000 2009-07-01 8:51

Know how to code Regardless of what  I say you  will delete them  silly Post them.

Name: Anonymous 2010-12-17 1:20

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2010-12-17 1:22

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-02 23:57

Name: Sgt.Kabukiman潥쬾 2012-05-23 5:58

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List