70
70
****************************************************************************/
71
71
72
72
int nsh_fileapp (FAR struct nsh_vtbl_s * vtbl , FAR const char * cmd ,
73
- FAR char * * argv , FAR const char * redirfile_in ,
74
- FAR const char * redirfile_out , int oflags )
73
+ FAR char * * argv , FAR const struct nsh_param_s * param )
75
74
{
76
75
posix_spawn_file_actions_t file_actions ;
77
76
posix_spawnattr_t attr ;
@@ -107,39 +106,46 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
107
106
goto errout_with_actions ;
108
107
}
109
108
110
- /* Handle redirection of input */
111
-
112
- if (redirfile_in )
109
+ if (param )
113
110
{
114
- /* Set up to close open redirfile and set to stdin (0) */
111
+ /* Handle redirection of input */
115
112
116
- ret = posix_spawn_file_actions_addopen (& file_actions , 0 ,
117
- redirfile_in , O_RDONLY , 0 );
118
- if (ret != 0 )
113
+ if (param -> file_in )
119
114
{
120
- nsh_error (vtbl , g_fmtcmdfailed , cmd ,
121
- "posix_spawn_file_actions_addopen" ,
122
- NSH_ERRNO );
123
- goto errout_with_actions ;
115
+ /* Set up to close open redirfile and set to stdin (0) */
116
+
117
+ ret = posix_spawn_file_actions_addopen (& file_actions , 0 ,
118
+ param -> file_in ,
119
+ param -> oflags_in ,
120
+ 0 );
121
+ if (ret != 0 )
122
+ {
123
+ nsh_error (vtbl , g_fmtcmdfailed , cmd ,
124
+ "posix_spawn_file_actions_addopen" ,
125
+ NSH_ERRNO );
126
+ goto errout_with_actions ;
127
+ }
124
128
}
125
- }
126
129
127
- /* Handle re-direction of output */
130
+ /* Handle re-direction of output */
128
131
129
- if (redirfile_out )
130
- {
131
- ret = posix_spawn_file_actions_addopen (& file_actions , 1 , redirfile_out ,
132
- oflags , 0644 );
133
- if (ret != 0 )
132
+ if (param -> file_out )
134
133
{
135
- /* posix_spawn_file_actions_addopen returns a positive errno
136
- * value on failure.
137
- */
134
+ ret = posix_spawn_file_actions_addopen (& file_actions , 1 ,
135
+ param -> file_out ,
136
+ param -> oflags_out ,
137
+ 0644 );
138
+ if (ret != 0 )
139
+ {
140
+ /* posix_spawn_file_actions_addopen returns a positive errno
141
+ * value on failure.
142
+ */
138
143
139
- nsh_error (vtbl , g_fmtcmdfailed , cmd ,
140
- "posix_spawn_file_actions_addopen" ,
141
- NSH_ERRNO );
142
- goto errout_with_attrs ;
144
+ nsh_error (vtbl , g_fmtcmdfailed , cmd ,
145
+ "posix_spawn_file_actions_addopen" ,
146
+ NSH_ERRNO );
147
+ goto errout_with_attrs ;
148
+ }
143
149
}
144
150
}
145
151
@@ -151,7 +157,7 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
151
157
if (index >= 0 )
152
158
{
153
159
FAR const struct builtin_s * builtin ;
154
- struct sched_param param ;
160
+ struct sched_param sched ;
155
161
156
162
/* Get information about the builtin */
157
163
@@ -164,8 +170,8 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
164
170
165
171
/* Set the correct task size and priority */
166
172
167
- param .sched_priority = builtin -> priority ;
168
- ret = posix_spawnattr_setschedparam (& attr , & param );
173
+ sched .sched_priority = builtin -> priority ;
174
+ ret = posix_spawnattr_setschedparam (& attr , & sched );
169
175
if (ret != 0 )
170
176
{
171
177
goto errout_with_actions ;
@@ -298,9 +304,9 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
298
304
299
305
#if !defined(CONFIG_SCHED_WAITPID ) || !defined(CONFIG_NSH_DISABLEBG )
300
306
{
301
- struct sched_param param ;
302
- sched_getparam (ret , & param );
303
- nsh_output (vtbl , "%s [%d:%d]\n" , cmd , ret , param .sched_priority );
307
+ struct sched_param sched ;
308
+ sched_getparam (ret , & sched );
309
+ nsh_output (vtbl , "%s [%d:%d]\n" , cmd , ret , sched .sched_priority );
304
310
305
311
/* Backgrounded commands always 'succeed' as long as we can start
306
312
* them.
0 commit comments