Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Willers
KWSys
Commits
cce4320a
Commit
cce4320a
authored
21 years ago
by
Brad King
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Implemented SetCommand and AddCommand for multiple process support.
parent
bcf39df0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProcessUNIX.c
+88
-18
88 additions, 18 deletions
ProcessUNIX.c
with
88 additions
and
18 deletions
ProcessUNIX.c
+
88
−
18
View file @
cce4320a
...
@@ -80,8 +80,9 @@ static void kwsysProcessRestoreDefaultSignalHandlers();
...
@@ -80,8 +80,9 @@ static void kwsysProcessRestoreDefaultSignalHandlers();
/* Structure containing data used to implement the child's execution. */
/* Structure containing data used to implement the child's execution. */
struct
kwsysProcess_s
struct
kwsysProcess_s
{
{
/* The command line to execute. */
/* The command lines to execute. */
char
**
Command
;
char
***
Commands
;
int
NumberOfCommands
;
/* Descriptors for the read ends of the child's output pipes. */
/* Descriptors for the read ends of the child's output pipes. */
int
PipeReadEnds
[
KWSYSPE_PIPE_COUNT
];
int
PipeReadEnds
[
KWSYSPE_PIPE_COUNT
];
...
@@ -173,32 +174,101 @@ void kwsysProcess_Delete(kwsysProcess* cp)
...
@@ -173,32 +174,101 @@ void kwsysProcess_Delete(kwsysProcess* cp)
}
}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
void
kwsysProcess_SetCommand
(
kwsysProcess
*
cp
,
char
const
*
const
*
command
)
int
kwsysProcess_SetCommand
(
kwsysProcess
*
cp
,
char
const
*
const
*
command
)
{
{
if
(
cp
->
Command
)
int
i
;
for
(
i
=
0
;
i
<
cp
->
NumberOfCommands
;
++
i
)
{
{
char
**
c
=
cp
->
Command
;
char
**
c
=
cp
->
Command
s
[
i
]
;
while
(
*
c
)
while
(
*
c
)
{
{
free
(
*
c
++
);
free
(
*
c
++
);
}
}
free
(
cp
->
Command
);
free
(
cp
->
Commands
[
i
]);
cp
->
Command
=
0
;
}
cp
->
NumberOfCommands
=
0
;
if
(
cp
->
Commands
)
{
free
(
cp
->
Commands
);
cp
->
Commands
=
0
;
}
}
if
(
command
)
if
(
command
)
{
{
char
const
*
const
*
c
=
command
;
return
kwsysProcess_AddCommand
(
cp
,
command
);
int
n
=
0
;
}
int
i
=
0
;
return
1
;
while
(
*
c
++
);
}
n
=
c
-
command
-
1
;
cp
->
Command
=
(
char
**
)
malloc
((
n
+
1
)
*
sizeof
(
char
*
));
/*--------------------------------------------------------------------------*/
for
(
i
=
0
;
i
<
n
;
++
i
)
int
kwsysProcess_AddCommand
(
kwsysProcess
*
cp
,
char
const
*
const
*
command
)
{
int
newNumberOfCommands
;
char
***
newCommands
;
/* Make sure we have a command to add. */
if
(
!
command
)
{
return
0
;
}
/* Allocate a new array for command pointers. */
newNumberOfCommands
=
cp
->
NumberOfCommands
+
1
;
if
(
!
(
newCommands
=
(
char
***
)
malloc
(
sizeof
(
char
**
)
*
newNumberOfCommands
)))
{
/* Out of memory. */
return
0
;
}
/* Copy any existing commands into the new array. */
{
int
i
;
for
(
i
=
0
;
i
<
cp
->
NumberOfCommands
;
++
i
)
{
newCommands
[
i
]
=
cp
->
Commands
[
i
];
}
}
/* Add the new command. */
{
char
const
*
const
*
c
=
command
;
int
n
=
0
;
int
i
=
0
;
while
(
*
c
++
);
n
=
c
-
command
-
1
;
newCommands
[
cp
->
NumberOfCommands
]
=
(
char
**
)
malloc
((
n
+
1
)
*
sizeof
(
char
*
));
if
(
!
newCommands
[
cp
->
NumberOfCommands
])
{
/* Out of memory. */
free
(
newCommands
);
return
0
;
}
for
(
i
=
0
;
i
<
n
;
++
i
)
{
newCommands
[
cp
->
NumberOfCommands
][
i
]
=
strdup
(
command
[
i
]);
if
(
!
newCommands
[
cp
->
NumberOfCommands
][
i
])
{
{
cp
->
Command
[
i
]
=
strdup
(
command
[
i
])
;
break
;
}
}
cp
->
Command
[
n
]
=
0
;
}
}
if
(
i
<
n
)
{
/* Out of memory. */
for
(;
i
>
0
;
--
i
)
{
free
(
newCommands
[
cp
->
NumberOfCommands
][
i
-
1
]);
}
free
(
newCommands
);
return
0
;
}
newCommands
[
cp
->
NumberOfCommands
][
n
]
=
0
;
}
/* Successfully allocated new command array. Free the old array. */
free
(
cp
->
Commands
);
cp
->
Commands
=
newCommands
;
cp
->
NumberOfCommands
=
newNumberOfCommands
;
return
1
;
}
}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
...
@@ -401,8 +471,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
...
@@ -401,8 +471,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
}
}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
int
kwsysProcess_WaitForData
(
kwsysProcess
*
cp
,
int
pipes
,
char
**
data
,
int
*
length
,
int
kwsysProcess_WaitForData
(
kwsysProcess
*
cp
,
int
pipes
,
char
**
data
,
double
*
userTimeout
)
int
*
length
,
double
*
userTimeout
)
{
{
int
i
;
int
i
;
int
max
=
-
1
;
int
max
=
-
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment