Welcome, Guest. Please login or register.

Author Topic: Execute, System or RunCommand ?  (Read 2686 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Using printf from two processes simultanously can be dangerous (stdio isn't necessarily re-entrant). I'd recommend using kprintf and debug.lib (sas/c) or libdebug.a (gcc).

Quote
- What's the point in having the command executed with CreateNewProc if it only returns when it finishes anyway ?

CreateNewProc creates new process that runs 100% asyncronous from the parent. CreateNewProc returns as soon as the subproc has been launched, it does not wait for it to finish. Be careful to sync the start and exit or you will have random problems.

Here's an example of subprocess and IPC:
http://www.iki.fi/sintonen/src/ipc/
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Execute, System or RunCommand ?
« Reply #1 on: June 12, 2005, 01:50:57 AM »
@Thomas
Quote
You can use Printf (with a capital "P") for debug output into your Shell window. You shouldn't use ANSI functions at all when working with sub processes. AmigaOS is full of functions you can use safely instead.

I have to correct you here: dos.library I/O buffering isn't thread safe either (including Printf).

Obviously if you open new console and Printf to it, it will be safe.