Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. creating child process in c++

creating child process in c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxhelpquestion
10 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aqueel
    wrote on last edited by
    #1

    Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

    N V J C A 6 Replies Last reply
    0
    • A Aqueel

      Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      CreateProcess(...)


      Nibu thomas Software Developer

      1 Reply Last reply
      0
      • A Aqueel

        Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

        V Offline
        V Offline
        Vinaya
        wrote on last edited by
        #3

        see _execvp() [^] Vini

        1 Reply Last reply
        0
        • A Aqueel

          Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #4

          I am not going to give you an answer, because you did no give an explanation of what fork() does. You have received a couple of answers about generating a child process. What do you want to know precisely? INTP Every thing is relative...

          1 Reply Last reply
          0
          • A Aqueel

            Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            I'm not a linux expert but I think fork() creates a new thread and not a new process. Am I right (not sure at all about that). The previous answers you get was how to create a process (so run another executable). If you want to run a thread in parallel, then you have to look for CreateThread[^]

            R 1 Reply Last reply
            0
            • A Aqueel

              Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

              A Offline
              A Offline
              Aqueel
              wrote on last edited by
              #6

              Here is the discription of fork() function. "fork creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0." I wanted to do the same thing in win32. I do not want operating system to allocate saperate resourses to new process. Infact i want the process to share the same resourses that it's parent is using. Are you getting my point? Thank you. We Believe in Excellence

              R 1 Reply Last reply
              0
              • A Aqueel

                Hello I want to ask how can i create a child process in Win32 as we do in linux with the help of fork(). Thank you. We Believe in Excellence

                N Offline
                N Offline
                Nemanja Trifunovic
                wrote on last edited by
                #7

                There is no fork equivalent under Windows. I suggest you consider using threads rather than processes - that is the Windows way of handling concurrency.


                My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                J 1 Reply Last reply
                0
                • C Cedric Moonen

                  I'm not a linux expert but I think fork() creates a new thread and not a new process. Am I right (not sure at all about that). The previous answers you get was how to create a process (so run another executable). If you want to run a thread in parallel, then you have to look for CreateThread[^]

                  R Offline
                  R Offline
                  Ryan Binns
                  wrote on last edited by
                  #8

                  fork() creates a new process - an exact duplicate of the current process, including the current code location. You can do this:

                  switch(fork())
                  {
                  case 0:
                  // child process comes here
                  exit(0);
                  default:
                  // parent process comes here
                  break;
                  }

                  Ryan

                  "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                  1 Reply Last reply
                  0
                  • A Aqueel

                    Here is the discription of fork() function. "fork creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0." I wanted to do the same thing in win32. I do not want operating system to allocate saperate resourses to new process. Infact i want the process to share the same resourses that it's parent is using. Are you getting my point? Thank you. We Believe in Excellence

                    R Offline
                    R Offline
                    Ryan Binns
                    wrote on last edited by
                    #9

                    Look at CreateThread(). It's exactly what you're after. But read up on multithreading, because you obviously don't know a lot about it. It can be quite tricky to learn...

                    Ryan

                    "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                    1 Reply Last reply
                    0
                    • N Nemanja Trifunovic

                      There is no fork equivalent under Windows. I suggest you consider using threads rather than processes - that is the Windows way of handling concurrency.


                      My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                      J Offline
                      J Offline
                      jhwurmbach
                      wrote on last edited by
                      #10

                      Nemanja Trifunovic wrote:

                      I suggest you consider using threads rather than processes - that is the Windows way of handling concurrency.

                      Actually, its becoming more and more the Linux way of concurrency. NPTL is a stable working thread implementation.


                      "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups