+2015-01-15  Don Breazeal  <donb@codesourcery.com>
+
+       * gdb.base/attach-pie-noexec.exp: Use can_spawn_for_attach
+       instead of checking whether the target board is remote and
+       use spawn_wait_for_attach instead of exec/sleep.
+       * gdb.base/attach-twice.exp: Likewise.
+
 2015-01-15  Joel Brobecker  <brobecker@adacore.com>
 
        * gdb.ada/var_arr_attrs: New testcase.
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Manipulation with PID on target is not supported.
-if [is_remote target] then {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
     return 0
 }
 
-set testpid [eval exec $binfile &]
-exec sleep 2
+# Start the program running and then wait for a bit, to be sure
+# that it can be attached to.
+
+set testpid [spawn_wait_for_attach $binfile]
 
 gdb_start
 file delete -- $binfile
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Manipulation with PID on target is not supported.
-if [is_remote target] then {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
     return -1
 }
 
-set testpid [eval exec $binfile &]
-exec sleep 2
+# Start the program running and then wait for a bit, to be sure
+# that it can be attached to.
+
+set testpid [spawn_wait_for_attach $binfile]
 
 set parentpid 0