Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!public!car From: car@public.BTR.COM (Carlos Rimola-Sarti car@btr.com) Newsgroups: comp.os.os2.programmer Subject: Porting from Unix to OS/2 Message-ID: <3126@public.BTR.COM> Date: 19 Jun 91 22:47:05 GMT Organization: Communications Solutions, Inc. (CSI) Mountain View, California Lines: 42 I am in the process of porting a large piece of code from Unix to OS/2 and I was wondering if anyone has had similar experiences to mine. For background, the code that I am porting consists of a device driver, a daemon and an application. They all talk to each other via named pipes and/or device open/close/read/write/ioctl. One of the first things that I had to decide was what to do about the Unix fork() call. The application makes use of fork to spawn off background processes. The "right" thing to do is probably to redesign the app to use threads instead of fork(). However, the app will be thrown away and I only needed to verify that the other pieces are working. Because of this, I thought that moving the application to OS/2 would be made a lot easier if I could emulate fork. After thinking about it I decided that fork() could not be easily emulated using threads. A forked process inherits its own copy of the data segment (with current values) and also inherits other context like installed signal handlers (which this application makes use of). All of these characteristics convinced me that it would be easier to simulate fork() by spawning an OS/2 process. I have been able to come up with a scheme (hack?) that works but I still have a few questions: 1) Has anyone had a similar experience? what did you do? 2) Is there a way in OS/2 to start a second process without having to specify an executable file that the OS will have to load from disk? In other words, why can't I just tell the OS where the code is? 3) Is there a clean way for a process to determine that IT is the first process in a session? i.e., one that was not spawned off by another process in the same session. 4) I would also like to hear about any other things to watch out for in porting code from one OS to the other and general comments on what others may have experienced. +---------------------------------------+-----------------------------------+ | Carlos Rimola-Sarti | email: car@btr.com | | Communications Solutions, Inc. | phone: 415-903-2585 | +---------------------------------------+-----------------------------------+